Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-08-14 04:22:47
Exec Total Coverage
Lines: 1658 4248 39.0%
Functions: 129 333 38.7%
Branches: 891 2760 32.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for ZQuest Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include "base/qrs.h"
15 #include "base/dmap.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 #include <map>
21 #include <filesystem>
22 #include <ctype.h>
23 #include <sstream>
24 #include "base/zc_alleg.h"
25 #include "gamedata.h"
26 #include "zc/zc_init.h"
27 #include "init.h"
28 #include "zc/replay.h"
29 #include "zc/cheats.h"
30 #include "zc/render.h"
31 #include "base/zc_math.h"
32 #include "base/zapp.h"
33 #include "dialog/cheatkeys.h"
34 #include "metadata/metadata.h"
35 #include "zc/zelda.h"
36 #include "tiles.h"
37 #include "base/colors.h"
38 #include "pal.h"
39 #include "base/zsys.h"
40 #include "qst.h"
41 #include "zc/zc_sys.h"
42 #include "play_midi.h"
43 #include "jwin_a5.h"
44 #include "base/jwinfsel.h"
45 #include "base/gui.h"
46 #include "midi.h"
47 #include "subscr.h"
48 #include "zc/maps.h"
49 #include "sprite.h"
50 #include "zc/guys.h"
51 #include "zc/hero.h"
52 #include "zc/title.h"
53 #include "particles.h"
54 #include "zcmusic.h"
55 #include "zconsole.h"
56 #include "zc/ffscript.h"
57 #include "dialog/info.h"
58 #include "dialog/alert.h"
59 #include "zc/combos.h"
60 #include "zc/jit.h"
61 #include <fmt/format.h>
62 #include "zinfo.h"
63 #include "base/misctypes.h"
64
65 #ifdef __EMSCRIPTEN__
66 #include "base/emscripten_utils.h"
67 #endif
68
69 extern FFScript FFCore;
70 extern bool Playing;
71 int32_t sfx_voice[WAV_COUNT];
72 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
73 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
74
75 extern byte monochrome_console;
76
77 extern HeroClass Hero;
78 extern FFScript FFCore;
79 extern ZModule zcm;
80 extern zcmodule moduledata;
81 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
82 extern particle_list particles;
83 extern int32_t loadlast;
84 extern char *sfx_string[WAV_COUNT];
85 byte use_dwm_flush;
86 byte use_save_indicator;
87 int32_t paused_midi_pos = 0;
88 byte midi_suspended = 0;
89 byte zc_192b163_warp_compatibility;
90 char modulepath[2048];
91 bool epilepsyFlashReduction;
92 signed char pause_in_background_menu_init = 0;
93 byte pause_in_background = 0;
94 bool is_sys_pal = false;
95 static bool load_control_called_this_frame;
96 extern PALETTE* hw_palette;
97 extern bool update_hw_pal;
98 extern const char* dmaplist(int32_t index, int32_t* list_size);
99 int32_t getnumber(const char *prompt,int32_t initialval);
100
101 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
102 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
103 //extern byte refresh_select_screen;
104 //extern movingblock mblock2; //mblock[4]?
105 //extern int32_t db;
106
107 static const char *ZC_str = "ZQuest Classic";
108 #if defined(ALLEGRO_WINDOWS)
109 const char *qst_dir_name = "win_qst_dir";
110 static const char *qst_module_name = "current_module";
111 #elif defined(ALLEGRO_LINUX)
112 const char *qst_dir_name = "linux_qst_dir";
113 static const char *qst_module_name = "current_module";
114 #elif defined(__APPLE__)
115 const char *qst_dir_name = "osx_qst_dir";
116 static const char *qst_module_name = "current_module";
117 #endif
118 #ifdef ALLEGRO_LINUX
119 static const char *samplepath = "samplesoundset/patches.dat";
120 #endif
121 char qst_files_path[2048];
122
123 #ifdef _MSC_VER
124 #define getcwd _getcwd
125 #endif
126
127 bool rF11();
128 bool rI();
129 bool rQ();
130 bool zc_key_pressed();
131
132 #ifdef _WIN32
133
134 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
135 extern "C"
136 {
137 typedef HRESULT(WINAPI *t_DwmFlush)();
138 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
139 }
140
141 void do_DwmFlush()
142 {
143 static HMODULE shell = LoadLibrary("dwmapi.dll");
144
145 if(!shell)
146 return;
147
148 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
149 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
150
151 BOOL enabled;
152 isEnabled(&enabled);
153
154 if(isEnabled)
155 flush();
156 }
157
158 #endif // _WIN32
159
160 83751 bool flash_reduction_enabled(bool check_qr)
161 {
162
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
163 }
164
165 // Dialogue largening
166 void large_dialog(DIALOG *d)
167 {
168 large_dialog(d, 1.5);
169 }
170
171 void large_dialog(DIALOG *d, float RESIZE_AMT)
172 {
173 if(!d[0].d1)
174 {
175 d[0].d1 = 1;
176 int32_t oldwidth = d[0].w;
177 int32_t oldheight = d[0].h;
178 int32_t oldx = d[0].x;
179 int32_t oldy = d[0].y;
180 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
181 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
182 d[0].w = int32_t(d[0].w*RESIZE_AMT);
183 d[0].h = int32_t(d[0].h*RESIZE_AMT);
184
185 for(int32_t i=1; d[i].proc !=NULL; i++)
186 {
187 // Place elements horizontally
188 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
189 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
190
191 if(d[i].proc != d_stringloader)
192 {
193 if(d[i].proc==d_bitmap_proc)
194 {
195 d[i].w *= 2;
196 }
197 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
198 }
199
200 // Place elements vertically
201 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
202 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
203
204 // Vertically resize elements
205 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
206 {
207 d[i].h = int32_t((double)d[i].h*1.5);
208 }
209 else if(d[i].proc == jwin_droplist_proc)
210 {
211 d[i].y += int32_t((double)d[i].h*0.25);
212 d[i].h = int32_t((double)d[i].h*1.25);
213 }
214 else if(d[i].proc==d_bitmap_proc)
215 {
216 d[i].h *= 2;
217 }
218 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
219
220 // Fix frames
221 if(d[i].proc == jwin_frame_proc)
222 {
223 d[i].x++;
224 d[i].y++;
225 d[i].w-=4;
226 d[i].h-=4;
227 }
228 }
229 }
230
231 for(int32_t i=1; d[i].proc!=NULL; i++)
232 {
233 if(d[i].proc==jwin_slider_proc)
234 continue;
235
236 // Bigger font
237 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
238
239 if(!d[i].dp2 && bigfontproc)
240 {
241 d[i].dp2 = get_zc_font(font_lfont_l);
242 }
243 else if(!bigfontproc)
244 {
245 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
246 }
247
248 // Make checkboxes work
249 if(d[i].proc == jwin_check_proc)
250 d[i].proc = jwin_checkfont_proc;
251 else if(d[i].proc == jwin_radio_proc)
252 d[i].proc = jwin_radiofont_proc;
253 }
254
255 jwin_center_dialog(d);
256 }
257
258
259 /**********************************/
260 /******** System functions ********/
261 /**********************************/
262
263 static char cfg_sect[] = "zeldadx"; //We need to rename this.
264 static char ctrl_sect[] = "Controls";
265 static char sfx_sect[] = "Volume";
266
267 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
268 {
269 return D_O_K;
270 }
271
272 bool is_reserved_key(int c)
273 {
274 switch(c)
275 {
276 case KEY_ESC:
277 return true;
278 }
279 return false;
280 }
281 bool is_reserved_keycombo(int c, int modflag)
282 {
283 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
284 return true;
285 return false;
286 }
287 bool checkcheat(Cheat cheat)
288 {
289 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
290 return true; //Main key pressed
291 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
292 return true; //Alt key pressed
293 return false;
294 }
295 116 void load_default_cheatkeys()
296 {
297 116 memset(cheatkeys, 0, sizeof(cheatkeys));
298 116 cheatkeys[Cheat::Life][0] = KEY_H;
299 116 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
300 116 cheatkeys[Cheat::Magic][0] = KEY_M;
301 116 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
302 116 cheatkeys[Cheat::Rupies][0] = KEY_R;
303 116 cheatkeys[Cheat::Bombs][0] = KEY_B;
304 116 cheatkeys[Cheat::Arrows][0] = KEY_A;
305 116 cheatkeys[Cheat::Clock][0] = KEY_I;
306 116 cheatkeys[Cheat::Walls][0] = KEY_F11;
307 116 cheatkeys[Cheat::Fast][0] = KEY_Q;
308 116 cheatkeys[Cheat::Light][0] = KEY_L;
309 116 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
310 116 cheatkeys[Cheat::Kill][0] = KEY_K;
311 116 cheatkeys[Cheat::GoTo][0] = KEY_G;
312 116 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
313 116 cheatkeys[Cheat::ShowL0][0] = KEY_0;
314 116 cheatkeys[Cheat::ShowL1][0] = KEY_1;
315 116 cheatkeys[Cheat::ShowL2][0] = KEY_2;
316 116 cheatkeys[Cheat::ShowL3][0] = KEY_3;
317 116 cheatkeys[Cheat::ShowL4][0] = KEY_4;
318 116 cheatkeys[Cheat::ShowL5][0] = KEY_5;
319 116 cheatkeys[Cheat::ShowL6][0] = KEY_6;
320 116 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
321 116 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
322 116 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
323 116 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
324 116 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
325 116 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
326 116 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
327 116 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
328 116 }
329 116 void load_game_configs()
330 {
331 116 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
332 116 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
333 116 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
334 116 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
335 116 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
336 116 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
337 116 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
338 116 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
339 116 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
340 116 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
341 116 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
342 116 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
343 116 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
344 116 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
345 116 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
346
347 //cheat modifier keya
348 116 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
349 116 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
350 116 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
351 116 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
352
353 //cheat keys
354 116 load_default_cheatkeys();
355 char buf[256];
356
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 116 times.
4176 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 if(!bindable_cheat((Cheat)q)) continue;
359 4060 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 util::lowerstr(cheatname);
361 4060 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 4060 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
365 4060 }
366
367
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
368 joystick_index = 0;
369
370 116 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
371 116 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
372 116 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
373 116 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
374 116 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
375 116 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
376 116 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
377 116 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
378 116 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
379 116 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
380
381 116 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
382 116 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
383 116 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
384 116 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
385
386 116 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
387 116 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
388 116 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
389 116 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
390 116 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
391 116 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
392 116 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
393 116 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
394 116 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
395 116 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
396 116 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
397
398 116 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
399 116 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
400 116 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
401 116 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
402
403 116 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
404
405 116 digi_volume = zc_get_config(sfx_sect,"digi",248);
406 116 midi_volume = zc_get_config(sfx_sect,"midi",255);
407 116 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
408 116 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
409 116 pan_style = zc_get_config(sfx_sect,"pan",1);
410 // 1 <= zcmusic_bufsz <= 128
411 116 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
412 116 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
413 116 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
414 116 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
415 116 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
416 116 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
417 116 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
418 #ifdef __EMSCRIPTEN__
419 if (em_is_mobile()) NameEntryMode = 2;
420 #endif
421 116 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
422 116 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
423 116 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
424 116 title_version = zc_get_config(cfg_sect,"title",2);
425 116 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
426 116 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
427
428 //default - scale x2, 640 x 480
429 116 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
430 116 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
431 116 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
432 116 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
433 116 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
434 116 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
435 116 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
436
437 116 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 116 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 116 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 116 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
455 #else //UNIX
456 116 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
457 116 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
458 116 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #endif
460 116 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
461 116 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
462
463 116 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
464
465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(strlen(qstdir)==0)
466 {
467 116 getcwd(qstdir,2048);
468 116 fix_filename_case(qstdir);
469 116 fix_filename_slashes(qstdir);
470 116 put_backslash(qstdir);
471 116 }
472 else
473 {
474 chop_path(qstdir);
475 }
476
477 116 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
478 116 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
479 116 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
480 116 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
481 116 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
482 116 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
483 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
484 116 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
485 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
486 116 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
487 116 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
488 116 }
489
490 void save_control_configs(bool kb)
491 {
492 if(kb)
493 {
494 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
495 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
496 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
498
499 if (!replay_is_replaying())
500 {
501 zc_set_config(ctrl_sect,"key_a",Akey);
502 zc_set_config(ctrl_sect,"key_b",Bkey);
503 zc_set_config(ctrl_sect,"key_s",Skey);
504 zc_set_config(ctrl_sect,"key_l",Lkey);
505 zc_set_config(ctrl_sect,"key_r",Rkey);
506 zc_set_config(ctrl_sect,"key_p",Pkey);
507 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
508 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
509 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
510 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
511 zc_set_config(ctrl_sect,"key_up", DUkey);
512 zc_set_config(ctrl_sect,"key_down", DDkey);
513 zc_set_config(ctrl_sect,"key_left", DLkey);
514 zc_set_config(ctrl_sect,"key_right",DRkey);
515 }
516 }
517 else
518 {
519 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
520 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
521 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
522 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
523 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
524 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
525 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
533
534 zc_set_config(ctrl_sect,"btn_a",Abtn);
535 zc_set_config(ctrl_sect,"btn_b",Bbtn);
536 zc_set_config(ctrl_sect,"btn_s",Sbtn);
537 zc_set_config(ctrl_sect,"btn_m",Mbtn);
538 zc_set_config(ctrl_sect,"btn_l",Lbtn);
539 zc_set_config(ctrl_sect,"btn_r",Rbtn);
540 zc_set_config(ctrl_sect,"btn_p",Pbtn);
541 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
542 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
543 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
544 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
545
546 zc_set_config(ctrl_sect,"btn_up",DUbtn);
547 zc_set_config(ctrl_sect,"btn_down",DDbtn);
548 zc_set_config(ctrl_sect,"btn_left",DLbtn);
549 zc_set_config(ctrl_sect,"btn_right",DRbtn);
550 }
551 }
552
553 void save_cheatkeys()
554 {
555 char buf[256];
556 for(size_t q = 1; q < Cheat::Last; ++q)
557 {
558 if(!bindable_cheat((Cheat)q)) continue;
559 std::string cheatname = cheat_to_string((Cheat)q);
560 util::lowerstr(cheatname);
561 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
562 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
563 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
564 if(cheatkeys[q][1])
565 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
566 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
567 }
568 }
569
570 void save_game_configs()
571 {
572 packfile_password("");
573
574 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
575
576 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
577 {
578 int o_window_x, o_window_y;
579 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
580 zc_set_config(cfg_sect,"window_x",o_window_x);
581 zc_set_config(cfg_sect,"window_y",o_window_y);
582 }
583
584 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
585 {
586 double monitor_scale = zc_get_monitor_scale();
587 window_width = al_get_display_width(all_get_display()) / monitor_scale;
588 window_height = al_get_display_height(all_get_display()) / monitor_scale;
589 zc_set_config(cfg_sect,"window_width",window_width);
590 zc_set_config(cfg_sect,"window_height",window_height);
591 }
592
593 zc_set_config(cfg_sect,"load_last",loadlast);
594 chop_path(qstdir);
595 zc_set_config(cfg_sect,qst_dir_name,qstdir);
596 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
597
598 flush_config_file();
599 #ifdef __EMSCRIPTEN__
600 em_sync_fs();
601 #endif
602 }
603
604 //----------------------------------------------------------------
605
606 // Timers
607
608 29409 void fps_callback()
609 {
610 29409 lastfps=framecnt;
611 29409 dword tempsecs = fps_secs;
612 29409 ++tempsecs;
613 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
614 29409 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
615 29409 ++fps_secs;
616 29409 framecnt=0;
617 29409 }
618
619 END_OF_FUNCTION(fps_callback)
620
621 116 int32_t Z_init_timers()
622 {
623 static bool didit = false;
624 const static char *err_str = "Couldn't allocate timer";
625 116 err_str = err_str; //Unused variable warning
626
627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(didit)
628 return 1;
629
630 116 didit = true;
631
632 LOCK_VARIABLE(lastfps);
633 LOCK_VARIABLE(framecnt);
634 LOCK_FUNCTION(fps_callback);
635
636
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
637 return 0;
638
639 116 return 1;
640 116 }
641
642 void Z_remove_timers()
643 {
644 remove_int(fps_callback);
645 }
646
647 //----------------------------------------------------------------
648
649 void go()
650 {
651 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
652 }
653
654 void comeback()
655 {
656 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
657 }
658
659 void dump_pal(BITMAP *dest)
660 {
661 for(int32_t i=0; i<256; i++)
662 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
663 }
664
665 //----------------------------------------------------------------
666
667 int game_mouse_index = ZCM_BLANK;
668 static bool system_mouse = false;
669 26 bool sys_mouse()
670 {
671 26 system_mouse = true;
672 26 return MouseSprite::set(ZCM_NORMAL);
673 }
674 555 bool game_mouse()
675 {
676 555 system_mouse = false;
677 555 return MouseSprite::set(game_mouse_index);
678 }
679 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
680 {
681 if(!bmp)
682 return;
683 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
684 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
685 if(bmp->w == scaledw && bmp->h == scaledh)
686 user_scale = false;
687 if(user_scale || sys_recolor)
688 {
689 if(!user_scale) scale = 1;
690 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
691 if(user_scale)
692 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
693 else
694 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
695 if(sys_recolor)
696 recolor_mouse(tmpbmp);
697 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
698 destroy_bitmap(tmpbmp);
699 }
700 else
701 {
702 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
703 }
704 }
705
706 //Handles converting the mouse sprite from the .dat file
707 void recolor_mouse(BITMAP* bmp)
708 {
709 for(int32_t x = 0; x < bmp->w; ++x)
710 {
711 for(int32_t y = 0; y < bmp->h; ++y)
712 {
713 int32_t color = getpixel(bmp, x, y);
714 switch(color)
715 {
716 case dvc(1):
717 color = jwin_pal[jcCURSORMISC];
718 break;
719 case dvc(2):
720 color = jwin_pal[jcCURSOROUTLINE];
721 break;
722 case dvc(3):
723 color = jwin_pal[jcCURSORLIGHT];
724 break;
725 case dvc(5):
726 color = jwin_pal[jcCURSORDARK];
727 break;
728 default:
729 continue;
730 }
731 putpixel(bmp, x, y, color);
732 }
733 }
734 }
735 void load_mouse()
736 {
737 enter_sys_pal();
738 MouseSprite::set(-1);
739 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
740 int32_t sz = 16*scale;
741 for(int32_t j = 0; j < 1; ++j)
742 {
743 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
744 if(zcmouse[j])
745 destroy_bitmap(zcmouse[j]);
746 zcmouse[j] = create_bitmap_ex(8,sz,sz);
747 clear_bitmap(zcmouse[j]);
748 clear_bitmap(tmpbmp);
749 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
750 recolor_mouse(tmpbmp);
751 if(sz!=16)
752 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
753 else
754 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
755 destroy_bitmap(tmpbmp);
756 }
757 if(!hw_palette) hw_palette = &RAMpal;
758 zc_set_palette(*hw_palette);
759
760 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
761 clear_bitmap(blankmouse);
762
763 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
764 MouseSprite::assign(ZCM_BLANK, blankmouse);
765 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
766
767 //Reload the mouse
768 if(system_mouse)
769 sys_mouse();
770 else game_mouse();
771
772 destroy_bitmap(blankmouse);
773 exit_sys_pal();
774 }
775
776 // sets the video mode and initializes the palette and mouse sprite
777 116 bool game_vid_mode(int32_t mode,int32_t wait)
778 {
779
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (is_headless())
780 116 return true;
781
782 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
783 {
784 return false;
785 }
786
787 scrx = (resx-320)>>1;
788 scry = (resy-240)>>1;
789 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
790 zcmouse[q] = NULL;
791 load_mouse();
792
793 for(int32_t i=240; i<256; i++)
794 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
795
796 zc_set_palette(RAMpal);
797 clear_to_color(screen,BLACK);
798
799 rest(wait);
800 return true;
801 116 }
802
803 8 void null_quest()
804 {
805 char qstdat_string[2048];
806 8 strcpy(qstdat_string, "modules/classic/default.qst");
807
808 #ifdef __EMSCRIPTEN__
809 // The quest template data file is not included because it's really big and isn't really needed
810 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
811 // which is much smaller.
812 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
813 #endif
814
815 8 byte skip_flags[4] = { 0 };
816
817 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
818 8 }
819
820 8 void init_NES_mode()
821 {
822 8 null_quest();
823 8 }
824
825 //----------------------------------------------------------------
826
827 qword trianglelines[16]=
828 {
829 0x0000000000000000ULL,
830 0xFD00000000000000ULL,
831 0xFDFD000000000000ULL,
832 0xFDFDFD0000000000ULL,
833 0xFDFDFDFD00000000ULL,
834 0xFDFDFDFDFD000000ULL,
835 0xFDFDFDFDFDFD0000ULL,
836 0xFDFDFDFDFDFDFD00ULL,
837 0xFDFDFDFDFDFDFDFDULL,
838 0x00FDFDFDFDFDFDFDULL,
839 0x0000FDFDFDFDFDFDULL,
840 0x000000FDFDFDFDFDULL,
841 0x00000000FDFDFDFDULL,
842 0x0000000000FDFDFDULL,
843 0x000000000000FDFDULL,
844 0x00000000000000FDULL,
845 };
846
847 word screen_triangles[28][32];
848 /*
849 qword triangles[4][16]= //[direction][value]
850 {
851 {
852 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
853 },
854 {
855 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
856 },
857 {
858 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
859 },
860 {
861 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
862 }
863 };
864 */
865
866
867 /*
868 byte triangles[4][16][8]= //[direction][value][line]
869 {
870 {
871 {
872 0, 0, 0, 0, 0, 0, 0, 0
873 },
874 {
875 1, 0, 0, 0, 0, 0, 0, 0
876 },
877 {
878 2, 1, 0, 0, 0, 0, 0, 0
879 },
880 {
881 3, 2, 1, 0, 0, 0, 0, 0
882 },
883 {
884 4, 3, 2, 1, 0, 0, 0, 0
885 },
886 {
887 5, 4, 3, 2, 1, 0, 0, 0
888 },
889 {
890 6, 5, 4, 3, 2, 1, 0, 0
891 },
892 {
893 7, 6, 5, 4, 3, 2, 1, 0
894 },
895 {
896 8, 7, 6, 5, 4, 3, 2, 1
897 },
898 {
899 8, 8, 7, 6, 5, 4, 3, 2
900 },
901 {
902 8, 8, 8, 7, 6, 5, 4, 3
903 },
904 {
905 8, 8, 8, 8, 7, 6, 5, 4
906 },
907 {
908 8, 8, 8, 8, 8, 7, 6, 5
909 },
910 {
911 8, 8, 8, 8, 8, 8, 7, 6
912 },
913 {
914 8, 8, 8, 8, 8, 8, 8, 7
915 },
916 {
917 8, 8, 8, 8, 8, 8, 8, 8
918 }
919 },
920 {
921 {
922 0, 0, 0, 0, 0, 0, 0, 0
923 },
924 {
925 15, 0, 0, 0, 0, 0, 0, 0
926 },
927 {
928 14, 15, 0, 0, 0, 0, 0, 0
929 },
930 {
931 13, 14, 15, 0, 0, 0, 0, 0
932 },
933 {
934 12, 13, 14, 15, 0, 0, 0, 0
935 },
936 {
937 11, 12, 13, 14, 15, 0, 0, 0
938 },
939 {
940 10, 11, 12, 13, 14, 15, 0, 0
941 },
942 {
943 9, 10, 11, 12, 13, 14, 15, 0
944 },
945 {
946 8, 9, 10, 11, 12, 13, 14, 15
947 },
948 {
949 8, 8, 9, 10, 11, 12, 13, 14
950 },
951 {
952 8, 8, 8, 9, 10, 11, 12, 13
953 },
954 {
955 8, 8, 8, 8, 9, 10, 11, 12
956 },
957 {
958 8, 8, 8, 8, 8, 9, 10, 11
959 },
960 {
961 8, 8, 8, 8, 8, 8, 9, 10
962 },
963 {
964 8, 8, 8, 8, 8, 8, 8, 9
965 },
966 {
967 8, 8, 8, 8, 8, 8, 8, 8
968 }
969 },
970 {
971 {
972 0, 0, 0, 0, 0, 0, 0, 0
973 },
974 {
975 0, 0, 0, 0, 0, 0, 0, 1
976 },
977 {
978 0, 0, 0, 0, 0, 0, 1, 2
979 },
980 {
981 0, 0, 0, 0, 0, 1, 2, 3
982 },
983 {
984 0, 0, 0, 0, 1, 2, 3, 4
985 },
986 {
987 0, 0, 0, 1, 2, 3, 4, 5
988 },
989 {
990 0, 0, 1, 2, 3, 4, 5, 6
991 },
992 {
993 0, 1, 2, 3, 4, 5, 6, 7
994 },
995 {
996 1, 2, 3, 4, 5, 6, 7, 8
997 },
998 {
999 2, 3, 4, 5, 6, 7, 8, 8
1000 },
1001 {
1002 3, 4, 5, 6, 7, 8, 8, 8
1003 },
1004 {
1005 4, 5, 6, 7, 8, 8, 8, 8
1006 },
1007 {
1008 5, 6, 7, 8, 8, 8, 8, 8
1009 },
1010 {
1011 6, 7, 8, 8, 8, 8, 8, 8
1012 },
1013 {
1014 7, 8, 8, 8, 8, 8, 8, 8
1015 },
1016 {
1017 8, 8, 8, 8, 8, 8, 8, 8
1018 }
1019 },
1020 {
1021 {
1022 0, 0, 0, 0, 0, 0, 0, 0
1023 },
1024 {
1025 0, 0, 0, 0, 0, 0, 0, 15
1026 },
1027 {
1028 0, 0, 0, 0, 0, 0, 15, 14
1029 },
1030 {
1031 0, 0, 0, 0, 0, 15, 14, 13
1032 },
1033 {
1034 0, 0, 0, 0, 15, 14, 13, 12
1035 },
1036 {
1037 0, 0, 0, 15, 14, 13, 12, 11
1038 },
1039 {
1040 0, 0, 15, 14, 13, 12, 11, 10
1041 },
1042 {
1043 0, 15, 14, 13, 12, 11, 10, 9
1044 },
1045 {
1046 15, 14, 13, 12, 11, 10, 9, 8
1047 },
1048 {
1049 14, 13, 12, 11, 10, 9, 8, 8
1050 },
1051 {
1052 13, 12, 11, 10, 9, 8, 8, 8
1053 },
1054 {
1055 12, 11, 10, 9, 8, 8, 8, 8
1056 },
1057 {
1058 11, 10, 9, 8, 8, 8, 8, 8
1059 },
1060 {
1061 10, 9, 8, 8, 8, 8, 8, 8
1062 },
1063 {
1064 9, 8, 8, 8, 8, 8, 8, 8
1065 },
1066 {
1067 8, 8, 8, 8, 8, 8, 8, 8
1068 }
1069 }
1070 };
1071 */
1072
1073
1074
1075 /*
1076 for (int32_t blockrow=0; blockrow<30; ++i)
1077 {
1078 for (int32_t linerow=0; linerow<8; ++i)
1079 {
1080 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1081 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1082 {
1083 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1084 ++triangleline;
1085 }
1086 }
1087 }
1088 */
1089
1090 // the ULL suffixes are to prevent this warning:
1091 // warning: integer constant is too large for "int32_t" type
1092
1093 qword triangles[4][16][8]= //[direction][value][line]
1094 {
1095 {
1096 {
1097 0x0000000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFD00000000000000ULL,
1108 0x0000000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFD000000000000ULL,
1118 0xFD00000000000000ULL,
1119 0x0000000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFD0000000000ULL,
1128 0xFDFD000000000000ULL,
1129 0xFD00000000000000ULL,
1130 0x0000000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFD00000000ULL,
1138 0xFDFDFD0000000000ULL,
1139 0xFDFD000000000000ULL,
1140 0xFD00000000000000ULL,
1141 0x0000000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFD000000ULL,
1148 0xFDFDFDFD00000000ULL,
1149 0xFDFDFD0000000000ULL,
1150 0xFDFD000000000000ULL,
1151 0xFD00000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFD0000ULL,
1158 0xFDFDFDFDFD000000ULL,
1159 0xFDFDFDFD00000000ULL,
1160 0xFDFDFD0000000000ULL,
1161 0xFDFD000000000000ULL,
1162 0xFD00000000000000ULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFD00ULL,
1168 0xFDFDFDFDFDFD0000ULL,
1169 0xFDFDFDFDFD000000ULL,
1170 0xFDFDFDFD00000000ULL,
1171 0xFDFDFD0000000000ULL,
1172 0xFDFD000000000000ULL,
1173 0xFD00000000000000ULL,
1174 0x0000000000000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFD00ULL,
1179 0xFDFDFDFDFDFD0000ULL,
1180 0xFDFDFDFDFD000000ULL,
1181 0xFDFDFDFD00000000ULL,
1182 0xFDFDFD0000000000ULL,
1183 0xFDFD000000000000ULL,
1184 0xFD00000000000000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFD00ULL,
1190 0xFDFDFDFDFDFD0000ULL,
1191 0xFDFDFDFDFD000000ULL,
1192 0xFDFDFDFD00000000ULL,
1193 0xFDFDFD0000000000ULL,
1194 0xFDFD000000000000ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFD00ULL,
1201 0xFDFDFDFDFDFD0000ULL,
1202 0xFDFDFDFDFD000000ULL,
1203 0xFDFDFDFD00000000ULL,
1204 0xFDFDFD0000000000ULL
1205 },
1206 {
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFD00ULL,
1212 0xFDFDFDFDFDFD0000ULL,
1213 0xFDFDFDFDFD000000ULL,
1214 0xFDFDFDFD00000000ULL
1215 },
1216 {
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFD00ULL,
1223 0xFDFDFDFDFDFD0000ULL,
1224 0xFDFDFDFDFD000000ULL
1225 },
1226 {
1227 0xFDFDFDFDFDFDFDFDULL,
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFD00ULL,
1234 0xFDFDFDFDFDFD0000ULL
1235 },
1236 {
1237 0xFDFDFDFDFDFDFDFDULL,
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFD00ULL
1245 },
1246 {
1247 0xFDFDFDFDFDFDFDFDULL,
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL
1255 }
1256 },
1257 {
1258 {
1259 0x0000000000000000ULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x00000000000000FDULL,
1270 0x0000000000000000ULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x000000000000FDFDULL,
1280 0x00000000000000FDULL,
1281 0x0000000000000000ULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0x0000000000FDFDFDULL,
1290 0x000000000000FDFDULL,
1291 0x00000000000000FDULL,
1292 0x0000000000000000ULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL
1297 },
1298 {
1299 0x00000000FDFDFDFDULL,
1300 0x0000000000FDFDFDULL,
1301 0x000000000000FDFDULL,
1302 0x00000000000000FDULL,
1303 0x0000000000000000ULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL
1307 },
1308 {
1309 0x000000FDFDFDFDFDULL,
1310 0x00000000FDFDFDFDULL,
1311 0x0000000000FDFDFDULL,
1312 0x000000000000FDFDULL,
1313 0x00000000000000FDULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL
1317 },
1318 {
1319 0x0000FDFDFDFDFDFDULL,
1320 0x000000FDFDFDFDFDULL,
1321 0x00000000FDFDFDFDULL,
1322 0x0000000000FDFDFDULL,
1323 0x000000000000FDFDULL,
1324 0x00000000000000FDULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL
1327 },
1328 {
1329 0x00FDFDFDFDFDFDFDULL,
1330 0x0000FDFDFDFDFDFDULL,
1331 0x000000FDFDFDFDFDULL,
1332 0x00000000FDFDFDFDULL,
1333 0x0000000000FDFDFDULL,
1334 0x000000000000FDFDULL,
1335 0x00000000000000FDULL,
1336 0x0000000000000000ULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0x00FDFDFDFDFDFDFDULL,
1341 0x0000FDFDFDFDFDFDULL,
1342 0x000000FDFDFDFDFDULL,
1343 0x00000000FDFDFDFDULL,
1344 0x0000000000FDFDFDULL,
1345 0x000000000000FDFDULL,
1346 0x00000000000000FDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0x00FDFDFDFDFDFDFDULL,
1352 0x0000FDFDFDFDFDFDULL,
1353 0x000000FDFDFDFDFDULL,
1354 0x00000000FDFDFDFDULL,
1355 0x0000000000FDFDFDULL,
1356 0x000000000000FDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0x00FDFDFDFDFDFDFDULL,
1363 0x0000FDFDFDFDFDFDULL,
1364 0x000000FDFDFDFDFDULL,
1365 0x00000000FDFDFDFDULL,
1366 0x0000000000FDFDFDULL
1367 },
1368 {
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0x00FDFDFDFDFDFDFDULL,
1374 0x0000FDFDFDFDFDFDULL,
1375 0x000000FDFDFDFDFDULL,
1376 0x00000000FDFDFDFDULL
1377 },
1378 {
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0x00FDFDFDFDFDFDFDULL,
1385 0x0000FDFDFDFDFDFDULL,
1386 0x000000FDFDFDFDFDULL
1387 },
1388 {
1389 0xFDFDFDFDFDFDFDFDULL,
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0x00FDFDFDFDFDFDFDULL,
1396 0x0000FDFDFDFDFDFDULL
1397 },
1398 {
1399 0xFDFDFDFDFDFDFDFDULL,
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0x00FDFDFDFDFDFDFDULL
1407 },
1408 {
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL
1417 }
1418 },
1419 {
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL
1449 },
1450 {
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0xFD00000000000000ULL,
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL
1459 },
1460 {
1461 0x0000000000000000ULL,
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0xFD00000000000000ULL,
1466 0xFDFD000000000000ULL,
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL
1469 },
1470 {
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0xFD00000000000000ULL,
1475 0xFDFD000000000000ULL,
1476 0xFDFDFD0000000000ULL,
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL
1479 },
1480 {
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0xFD00000000000000ULL,
1484 0xFDFD000000000000ULL,
1485 0xFDFDFD0000000000ULL,
1486 0xFDFDFDFD00000000ULL,
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL
1489 },
1490 {
1491 0x0000000000000000ULL,
1492 0xFD00000000000000ULL,
1493 0xFDFD000000000000ULL,
1494 0xFDFDFD0000000000ULL,
1495 0xFDFDFDFD00000000ULL,
1496 0xFDFDFDFDFD000000ULL,
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL
1499 },
1500 {
1501 0xFD00000000000000ULL,
1502 0xFDFD000000000000ULL,
1503 0xFDFDFD0000000000ULL,
1504 0xFDFDFDFD00000000ULL,
1505 0xFDFDFDFDFD000000ULL,
1506 0xFDFDFDFDFDFD0000ULL,
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFD000000000000ULL,
1512 0xFDFDFD0000000000ULL,
1513 0xFDFDFDFD00000000ULL,
1514 0xFDFDFDFDFD000000ULL,
1515 0xFDFDFDFDFDFD0000ULL,
1516 0xFDFDFDFDFDFDFD00ULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFD0000000000ULL,
1522 0xFDFDFDFD00000000ULL,
1523 0xFDFDFDFDFD000000ULL,
1524 0xFDFDFDFDFDFD0000ULL,
1525 0xFDFDFDFDFDFDFD00ULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 },
1530 {
1531 0xFDFDFDFD00000000ULL,
1532 0xFDFDFDFDFD000000ULL,
1533 0xFDFDFDFDFDFD0000ULL,
1534 0xFDFDFDFDFDFDFD00ULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL
1539 },
1540 {
1541 0xFDFDFDFDFD000000ULL,
1542 0xFDFDFDFDFDFD0000ULL,
1543 0xFDFDFDFDFDFDFD00ULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL
1549 },
1550 {
1551 0xFDFDFDFDFDFD0000ULL,
1552 0xFDFDFDFDFDFDFD00ULL,
1553 0xFDFDFDFDFDFDFDFDULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL
1559 },
1560 {
1561 0xFDFDFDFDFDFDFD00ULL,
1562 0xFDFDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL
1569 },
1570 {
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL
1579 }
1580 },
1581 {
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL
1611 },
1612 {
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x00000000000000FDULL,
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL
1621 },
1622 {
1623 0x0000000000000000ULL,
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x00000000000000FDULL,
1628 0x000000000000FDFDULL,
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL
1631 },
1632 {
1633 0x0000000000000000ULL,
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x00000000000000FDULL,
1637 0x000000000000FDFDULL,
1638 0x0000000000FDFDFDULL,
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL
1641 },
1642 {
1643 0x0000000000000000ULL,
1644 0x0000000000000000ULL,
1645 0x00000000000000FDULL,
1646 0x000000000000FDFDULL,
1647 0x0000000000FDFDFDULL,
1648 0x00000000FDFDFDFDULL,
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL
1651 },
1652 {
1653 0x0000000000000000ULL,
1654 0x00000000000000FDULL,
1655 0x000000000000FDFDULL,
1656 0x0000000000FDFDFDULL,
1657 0x00000000FDFDFDFDULL,
1658 0x000000FDFDFDFDFDULL,
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x00000000000000FDULL,
1664 0x000000000000FDFDULL,
1665 0x0000000000FDFDFDULL,
1666 0x00000000FDFDFDFDULL,
1667 0x000000FDFDFDFDFDULL,
1668 0x0000FDFDFDFDFDFDULL,
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x000000000000FDFDULL,
1674 0x0000000000FDFDFDULL,
1675 0x00000000FDFDFDFDULL,
1676 0x000000FDFDFDFDFDULL,
1677 0x0000FDFDFDFDFDFDULL,
1678 0x00FDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0x0000000000FDFDFDULL,
1684 0x00000000FDFDFDFDULL,
1685 0x000000FDFDFDFDFDULL,
1686 0x0000FDFDFDFDFDFDULL,
1687 0x00FDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 },
1692 {
1693 0x00000000FDFDFDFDULL,
1694 0x000000FDFDFDFDFDULL,
1695 0x0000FDFDFDFDFDFDULL,
1696 0x00FDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL
1701 },
1702 {
1703 0x000000FDFDFDFDFDULL,
1704 0x0000FDFDFDFDFDFDULL,
1705 0x00FDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL
1711 },
1712 {
1713 0x0000FDFDFDFDFDFDULL,
1714 0x00FDFDFDFDFDFDFDULL,
1715 0xFDFDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL
1721 },
1722 {
1723 0x00FDFDFDFDFDFDFDULL,
1724 0xFDFDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL
1731 },
1732 {
1733 0xFDFDFDFDFDFDFDFDULL,
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL
1741 }
1742 }
1743 };
1744
1745 int32_t black_opening_count=0;
1746 int32_t black_opening_x,black_opening_y;
1747 int32_t black_opening_shape;
1748
1749 1506 int32_t choose_opening_shape()
1750 {
1751 // First, count how many bits are set
1752 1506 int32_t numBits=0;
1753 int32_t bitCounter;
1754
1755
2/2
✓ Branch 0 taken 7530 times.
✓ Branch 1 taken 1506 times.
9036 for(int32_t i=0; i<bosMAX; i++)
1756 {
1757
2/2
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 1722 times.
7530 if(COOLSCROLL&(1<<i))
1758 1722 numBits++;
1759 7530 }
1760
1761 // Shouldn't happen...
1762
1/2
✓ Branch 0 taken 1506 times.
✗ Branch 1 not taken.
1506 if(numBits==0)
1763 return bosCIRCLE;
1764
1765 // Pick a bit
1766 1506 bitCounter=zc_rand()%numBits+1;
1767
1768
2/2
✓ Branch 0 taken 1991 times.
✓ Branch 1 taken 26 times.
2017 for(int32_t i=0; i<bosMAX; i++)
1769 {
1770 // If this bit is set, decrement the bit counter
1771
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1636 times.
1991 if(COOLSCROLL&(1<<i))
1772 1636 bitCounter--;
1773
1774 // When the counter hits 0, return a value based on
1775 // which bit it stopped on.
1776 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1777
2/2
✓ Branch 0 taken 1480 times.
✓ Branch 1 taken 511 times.
1991 if(bitCounter==0)
1778 1480 return i;
1779 511 }
1780
1781 // Shouldn't be necessary, but the compiler might complain, at least
1782 26 return bosCIRCLE;
1783 1506 }
1784
1785 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1786 {
1787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1788
1789 396 int32_t w=256, h=224;
1790 396 int32_t blockrows=28, blockcolumns=32;
1791 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1792
1793
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1794 {
1795
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1796 {
1797
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1798 354816 }
1799 11088 }
1800
1801 396 black_opening_count = 66;
1802 396 black_opening_x = x;
1803 396 black_opening_y = y;
1804 396 lensclk = 0;
1805 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1806
1807
1808
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1809 {
1810 refreshTints();
1811 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1812 }
1813
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1814 {
1815 FFCore.warpScriptCheck();
1816 for(int32_t i=0; i<66; i++)
1817 {
1818 draw_screen(tmpscr);
1819 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1820 advanceframe(true);
1821
1822 if(Quit)
1823 {
1824 break;
1825 }
1826 }
1827 }
1828 396 }
1829
1830 1110 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1831 {
1832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1110 times.
1110 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1833
1834 1110 int32_t w=256, h=224;
1835 1110 int32_t blockrows=28, blockcolumns=32;
1836 1110 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1837
1838
2/2
✓ Branch 0 taken 31080 times.
✓ Branch 1 taken 1110 times.
32190 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1839 {
1840
2/2
✓ Branch 0 taken 994560 times.
✓ Branch 1 taken 31080 times.
1025640 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1841 {
1842
2/2
✓ Branch 0 taken 442260 times.
✓ Branch 1 taken 552300 times.
994560 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1843 994560 }
1844 31080 }
1845
1846 1110 black_opening_count = -66;
1847 1110 black_opening_x = x;
1848 1110 black_opening_y = y;
1849 1110 lensclk = 0;
1850
1/2
✓ Branch 0 taken 1110 times.
✗ Branch 1 not taken.
1110 if(black_opening_shape == bosFADEBLACK)
1851 {
1852 refreshTints();
1853 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1854 }
1855
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 911 times.
1110 if(wait)
1856 {
1857 911 FFCore.warpScriptCheck();
1858
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 60126 times.
61037 for(int32_t i=0; i<66; i++)
1859 {
1860 60126 draw_screen(tmpscr);
1861 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1862 60126 advanceframe(true);
1863
1864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60126 times.
60126 if(Quit)
1865 {
1866 break;
1867 }
1868 60126 }
1869 911 }
1870 1110 }
1871
1872 99396 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1873 {
1874 99396 clear_to_color(tmp_scr,BLACK);
1875 99396 int32_t w=256, h=224;
1876
1877
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90222 times.
99396 switch(black_opening_shape)
1878 {
1879 case bosOVAL:
1880 {
1881 858 double new_w=(w/2)+abs(w/2-x);
1882 858 double new_h=(h/2)+abs(h/2-y);
1883 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1884 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1885 858 break;
1886 }
1887
1888 case bosTRIANGLE:
1889 {
1890 660 double new_w=(w/2)+abs(w/2-x);
1891 660 double new_h=(h/2)+abs(h/2-y);
1892 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1893 660 double P2= (PI/2);
1894 660 double P23=(2*PI/3);
1895 660 double P43=(4*PI/3);
1896 660 double Pa= (-4*PI*a/(3*max_a));
1897 660 double angle=P2+Pa;
1898 660 double a0=angle;
1899 660 double a2=angle+P23;
1900 660 double a4=angle+P43;
1901 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1902 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1903 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1904 0);
1905 660 break;
1906 }
1907
1908 case bosSMAS:
1909 {
1910
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1911
1912
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1913 {
1914
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1915 {
1916 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1917
1918
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1919 {
1920 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1921
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1922 54878208 [linerow];
1923 54878208 ++triangleline;
1924
1925
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1926 {
1927 6859776 }
1928 54878208 }
1929 1714944 }
1930 214368 }
1931
1932 7656 break;
1933 }
1934
1935 case bosFADEBLACK:
1936 {
1937 if(black_opening_count<0)
1938 {
1939 black_fade(zc_min(-black_opening_count,63));
1940 }
1941 else if(black_opening_count>0)
1942 {
1943 black_fade(63-zc_max(black_opening_count-3,0));
1944 }
1945 else black_fade(0);
1946 return; //no blitting from tmp_scr!
1947 }
1948
1949 90222 case bosCIRCLE:
1950 default:
1951 {
1952 90222 double new_w=(w/2)+abs(w/2-x);
1953 90222 double new_h=(h/2)+abs(h/2-y);
1954 90222 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1955 //circlefill(tmp_scr,x,y,a<<3,0);
1956 90222 circlefill(tmp_scr,x,y,r,0);
1957 90222 break;
1958 }
1959 }
1960
1961 99396 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1962 99396 }
1963
1964
1965 void black_fade(int32_t fadeamnt)
1966 {
1967 for(int32_t i=0; i < 0xEF; i++)
1968 {
1969 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1970 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1971 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1972 }
1973
1974 refreshpal = true;
1975 }
1976
1977 //----------------------------------------------------------------
1978
1979 38813571 bool item_disabled(int32_t item) //is this item disabled?
1980 {
1981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38813571 times.
38813571 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1982 }
1983
1984 7615632 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1985 {
1986
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7480384 times.
7615632 if(current_item(item_type, true) >=item)
1987 {
1988 135248 return true;
1989 }
1990
1991 7480384 return false;
1992 7615632 }
1993
1994 30661739 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1995 {
1996
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051811 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16010221 times.
✓ Branch 7 taken 5337683 times.
✓ Branch 8 taken 41747 times.
30661739 switch(item_type)
1997 {
1998 case itype_bomb:
1999 case itype_sbomb:
2000 {
2001 int32_t itemid = getItemID(itemsbuf, item_type, it);
2002
2003 if(itemid == -1)
2004 return false;
2005
2006 return (game->get_item(itemid));
2007 }
2008
2009 case itype_clock:
2010 {
2011 6051811 int32_t itemid = getItemID(itemsbuf, item_type, it);
2012
2013
2/4
✓ Branch 0 taken 6051811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051811 times.
✗ Branch 3 not taken.
6051811 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2014 return (game->get_item(itemid));
2015 6051811 return Hero.getClock()?1:0;
2016 }
2017
2018 case itype_key:
2019 return (game->get_keys()>0);
2020
2021 case itype_magiccontainer:
2022 return (game->get_maxmagic()>=game->get_mp_per_block());
2023
2024 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2025 {
2026
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2027 {
2028 case -2:
2029 {
2030 for(int32_t i=0; i<MAXLEVELS; i++)
2031 {
2032 if(game->lvlitems[i]&liTRIFORCE)
2033 {
2034 return true;
2035 }
2036 }
2037
2038 return false;
2039 }
2040
2041 case -1:
2042 return (game->lvlitems[dlevel]&liTRIFORCE);
2043
2044 default:
2045
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2046 {
2047 3220277 return (game->lvlitems[it]&liTRIFORCE);
2048 }
2049
2050 break;
2051 }
2052
2053 return 0;
2054 }
2055
2056 case itype_map: //it: -2=any, -1=current level, other=that level
2057 {
2058
1/3
✓ Branch 0 taken 16010221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16010221 switch(it)
2059 {
2060 case -2:
2061 {
2062 for(int32_t i=0; i<MAXLEVELS; i++)
2063 {
2064 if(game->lvlitems[i]&liMAP)
2065 {
2066 return true;
2067 }
2068 }
2069
2070 return false;
2071 }
2072
2073 case -1:
2074 return (game->lvlitems[dlevel]&liMAP)!=0;
2075
2076 default:
2077
2/4
✓ Branch 0 taken 16010221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16010221 times.
16010221 if(it>=0&&it<MAXLEVELS)
2078 {
2079 16010221 return (game->lvlitems[it]&liMAP)!=0;
2080 }
2081
2082 break;
2083 }
2084
2085 return 0;
2086 }
2087
2088 case itype_compass: //it: -2=any, -1=current level, other=that level
2089 {
2090
1/3
✓ Branch 0 taken 5337683 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5337683 switch(it)
2091 {
2092 case -2:
2093 {
2094 for(int32_t i=0; i<MAXLEVELS; i++)
2095 {
2096 if(game->lvlitems[i]&liCOMPASS)
2097 {
2098 return true;
2099 }
2100 }
2101
2102 return false;
2103 }
2104
2105 case -1:
2106 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2107
2108 default:
2109
2/4
✓ Branch 0 taken 5337683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5337683 times.
✗ Branch 3 not taken.
5337683 if(it>=0&&it<MAXLEVELS)
2110 {
2111 5337683 return (game->lvlitems[it]&liCOMPASS)!=0;
2112 }
2113
2114 break;
2115 }
2116 return 0;
2117 }
2118
2119 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2120 {
2121
1/3
✓ Branch 0 taken 41747 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
41747 switch(it)
2122 {
2123 case -2:
2124 {
2125 for(int32_t i=0; i<MAXLEVELS; i++)
2126 {
2127 if(game->lvlitems[i]&liBOSSKEY)
2128 {
2129 return true;
2130 }
2131 }
2132
2133 return false;
2134 }
2135
2136 case -1:
2137 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2138
2139 default:
2140
2/4
✓ Branch 0 taken 41747 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41747 times.
41747 if(it>=0&&it<MAXLEVELS)
2141 {
2142 41747 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2143 }
2144 break;
2145 }
2146 return 0;
2147 }
2148
2149 default:
2150 //it=(1<<(it-1));
2151 /*if (item_type>=itype_max)
2152 {
2153 enter_sys_pal();
2154 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2155 exit_sys_pal();
2156
2157 return false;
2158 }*/
2159 int32_t itemid = getItemID(itemsbuf, item_type, it);
2160
2161 if(itemid == -1)
2162 return false;
2163
2164 return game->get_item(itemid);
2165 }
2166 30661739 }
2167
2168
2169 99990255 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2170 {
2171
9/9
✓ Branch 0 taken 6051811 times.
✓ Branch 1 taken 51575767 times.
✓ Branch 2 taken 6051811 times.
✓ Branch 3 taken 6051811 times.
✓ Branch 4 taken 6051811 times.
✓ Branch 5 taken 6051811 times.
✓ Branch 6 taken 6051811 times.
✓ Branch 7 taken 6051811 times.
✓ Branch 8 taken 6051811 times.
99990255 switch(item_type)
2172 {
2173 case itype_clock:
2174 {
2175 6051811 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2176
2177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6051811 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6051811 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2178 return itemsbuf[maxid].fam_type;
2179
2180 6051811 return has_item(itype_clock,1) ? 1 : 0;
2181 }
2182
2183 case itype_key:
2184 6051811 return game->get_keys();
2185
2186 case itype_lkey:
2187 6051811 return game->lvlkeys[get_dlevel()];
2188
2189 case itype_magiccontainer:
2190 6051811 return game->get_maxmagic()/game->get_mp_per_block();
2191
2192 case itype_triforcepiece:
2193 {
2194 6051811 int32_t count=0;
2195
2196
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2197 {
2198 3098527232 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2199 3098527232 }
2200
2201 6051811 return count;
2202 }
2203
2204 case itype_map:
2205 {
2206 6051811 int32_t count=0;
2207
2208
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2209 {
2210 3098527232 count+=(game->lvlitems[i]&liMAP)?1:0;
2211 3098527232 }
2212
2213 6051811 return count;
2214 }
2215
2216 case itype_compass:
2217 {
2218 6051811 int32_t count=0;
2219
2220
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2221 {
2222 3098527232 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2223 3098527232 }
2224
2225 6051811 return count;
2226 }
2227
2228 case itype_bosskey:
2229 {
2230 6051811 int32_t count=0;
2231
2232
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2233 {
2234 3098527232 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2235 3098527232 }
2236
2237 6051811 return count;
2238 }
2239
2240 default:
2241 51575767 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2242
2243
2/2
✓ Branch 0 taken 9877334 times.
✓ Branch 1 taken 41698433 times.
51575767 if(maxid == -1)
2244 41698433 return 0;
2245
2246 9877334 return itemsbuf[maxid].fam_type;
2247 }
2248 99990255 }
2249
2250 92374623 int32_t current_item(int32_t item_type) //item currently being used
2251 {
2252 92374623 return current_item(item_type, true);
2253 }
2254
2255 116 std::map<int32_t, int32_t> itemcache;
2256
2257 // Not actually used by anything at the moment...
2258 void removeFromItemCache(int32_t itemclass)
2259 {
2260 itemcache.erase(itemclass);
2261 }
2262
2263 30026 void flushItemCache()
2264 {
2265 30026 itemcache.clear();
2266
2267 //also fix the active subscreen if items were deleted -DD
2268
1/2
✓ Branch 0 taken 30026 times.
✗ Branch 1 not taken.
30026 if(game != NULL)
2269 {
2270 30026 verifyBothWeapons();
2271 30026 load_Sitems();
2272 30026 }
2273 30026 }
2274
2275 // This is used often, so it should be as direct as possible.
2276 3372133296 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2277 {
2278
2/2
✓ Branch 0 taken 3296618299 times.
✓ Branch 1 taken 75514997 times.
3372133296 if(jinx_check)
2279 {
2280
4/4
✓ Branch 0 taken 47347658 times.
✓ Branch 1 taken 28167339 times.
✓ Branch 2 taken 39070031 times.
✓ Branch 3 taken 8277627 times.
75514997 if(!(HeroSwordClk() || HeroItemClk()))
2281 39070031 jinx_check = false; //not jinxed
2282 75514997 }
2283
4/4
✓ Branch 0 taken 3342722254 times.
✓ Branch 1 taken 29411042 times.
✓ Branch 2 taken 36112271 times.
✓ Branch 3 taken 3306609983 times.
3372133296 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2284 {
2285 3306609983 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2286
2287
2/2
✓ Branch 0 taken 3291279715 times.
✓ Branch 1 taken 15330268 times.
3306609983 if(res != itemcache.end())
2288 3291279715 return res->second;
2289 15330268 }
2290
2291 80853581 int32_t result = -1;
2292 80853581 int32_t highestlevel = -1;
2293
2294
2/2
✓ Branch 0 taken 20698516736 times.
✓ Branch 1 taken 80853581 times.
20779370317 for(int32_t i=0; i<MAXITEMS; i++)
2295 {
2296
5/6
✓ Branch 0 taken 1517290847 times.
✓ Branch 1 taken 19181225889 times.
✓ Branch 2 taken 21721442 times.
✓ Branch 3 taken 1495569405 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21721442 times.
20698516736 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2297 {
2298
4/4
✓ Branch 0 taken 5876352 times.
✓ Branch 1 taken 15845090 times.
✓ Branch 2 taken 1816039 times.
✓ Branch 3 taken 19905403 times.
21721442 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2299 {
2300 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2301
2/2
✓ Branch 0 taken 19905230 times.
✓ Branch 1 taken 173 times.
19905403 if(!checkmagiccost(i))
2302 {
2303
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 161 times.
173 if ( !get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2304 12 }
2305 19905242 }
2306
6/6
✓ Branch 0 taken 18413039 times.
✓ Branch 1 taken 3308242 times.
✓ Branch 2 taken 311736 times.
✓ Branch 3 taken 2996506 times.
✓ Branch 4 taken 1799132 times.
✓ Branch 5 taken 1509110 times.
21721281 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2307 {
2308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509110 times.
1509110 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2309 1509110 continue;
2310 }
2311
2312
2/2
✓ Branch 0 taken 278854 times.
✓ Branch 1 taken 19933317 times.
20212171 if(itemsbuf[i].fam_type >= highestlevel)
2313 {
2314 19933317 highestlevel = itemsbuf[i].fam_type;
2315 19933317 result=i;
2316 19933317 }
2317 20212171 }
2318 20697007465 }
2319
2320
2/2
✓ Branch 0 taken 36444966 times.
✓ Branch 1 taken 44408615 times.
80853581 if(!jinx_check) //Can't cache jinx_check results
2321 44408615 itemcache[itemtype] = result;
2322 80853581 return result;
2323 3372133296 }
2324
2325 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2326 3336132543 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2327 {
2328 3336132543 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2329
2/2
✓ Branch 0 taken 39514244 times.
✓ Branch 1 taken 3296618299 times.
3336132543 if(!jinx_check) //If not already a jinx-immune-only check...
2330 {
2331 //And the player IS jinxed...
2332
4/4
✓ Branch 0 taken 3268793937 times.
✓ Branch 1 taken 27824362 times.
✓ Branch 2 taken 8176391 times.
✓ Branch 3 taken 3260617546 times.
3296618299 if(HeroSwordClk() || HeroItemClk())
2333 {
2334 //Then do a jinx-immune-only check here
2335 36000753 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2336 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2337 //Should NOT need a compat rule, as this should always return -1 in old quests.
2338
2/2
✓ Branch 0 taken 1216689 times.
✓ Branch 1 taken 34784064 times.
36000753 if(ret2 > -1) return ret2;
2339 34784064 }
2340 3295401610 }
2341 3334915854 return ret;
2342 3336132543 }
2343 19237880 int32_t current_item_power(int32_t itemtype)
2344 {
2345 19237880 int32_t result = current_item_id(itemtype,true);
2346
2/2
✓ Branch 0 taken 13950304 times.
✓ Branch 1 taken 5287576 times.
19237880 return (result<0) ? 0 : itemsbuf[result].power;
2347 }
2348
2349 11 int32_t heart_container_id()
2350 {
2351
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2352 {
2353
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2354 {
2355 11 return i;
2356 }
2357 308 }
2358 return -1;
2359 11 }
2360
2361 6051811 int32_t item_tile_mod()
2362 {
2363 6051811 int32_t tile=0;
2364
2365
2/2
✓ Branch 0 taken 1204800 times.
✓ Branch 1 taken 4847011 times.
6051811 if(game->get_bombs())
2366 {
2367 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2368
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2369 4681842 tile+=itemsbuf[itemid].ltm;
2370 4847011 }
2371
2372
2/2
✓ Branch 0 taken 4537735 times.
✓ Branch 1 taken 1514076 times.
6051811 if(game->get_sbombs())
2373 {
2374 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2375
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2376 1512648 tile+=itemsbuf[itemid].ltm;
2377 1514076 }
2378
2379
2/2
✓ Branch 0 taken 5942111 times.
✓ Branch 1 taken 109700 times.
6051811 if(current_item(itype_clock))
2380 {
2381 109700 int32_t itemid =
2382
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2383 ? iClock
2384 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2385
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2386 109700 tile+=itemsbuf[itemid].ltm;
2387 109700 }
2388
2389
2/2
✓ Branch 0 taken 4671070 times.
✓ Branch 1 taken 1380741 times.
6051811 if(current_item(itype_key))
2390 {
2391 1380741 int32_t itemid =
2392
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2393 ? iKey
2394 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2395
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2396 1380741 tile+=itemsbuf[itemid].ltm;
2397 1380741 }
2398
2399
2/2
✓ Branch 0 taken 5784708 times.
✓ Branch 1 taken 267103 times.
6051811 if(current_item(itype_lkey))
2400 {
2401 267103 int32_t itemid =
2402
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2403 ? iLevelKey
2404 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2405
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2406 267103 tile+=itemsbuf[itemid].ltm;
2407 267103 }
2408
2409
2/2
✓ Branch 0 taken 1254994 times.
✓ Branch 1 taken 4796817 times.
6051811 if(current_item(itype_map))
2410 {
2411 4796817 int32_t itemid =
2412
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2413 ? iMap
2414 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2415
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2416 4796817 tile+=itemsbuf[itemid].ltm;
2417 4796817 }
2418
2419
2/2
✓ Branch 0 taken 1233112 times.
✓ Branch 1 taken 4818699 times.
6051811 if(current_item(itype_compass))
2420 {
2421 4818699 int32_t itemid =
2422
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2423 ? iCompass
2424 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2425
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2426 4818699 tile+=itemsbuf[itemid].ltm;
2427 4818699 }
2428
2429
2/2
✓ Branch 0 taken 3421266 times.
✓ Branch 1 taken 2630545 times.
6051811 if(current_item(itype_bosskey))
2430 {
2431 2630545 int32_t itemid =
2432
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2433 ? iBossKey
2434 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2435
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2436 2630545 tile+=itemsbuf[itemid].ltm;
2437 2630545 }
2438
2439
2/2
✓ Branch 0 taken 2917835 times.
✓ Branch 1 taken 3133976 times.
6051811 if(current_item(itype_magiccontainer))
2440 {
2441 3133976 int32_t itemid =
2442
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2443 ? iMagicC
2444 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2445
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2446 3132106 tile+=itemsbuf[itemid].ltm;
2447 3133976 }
2448
2449
2/2
✓ Branch 0 taken 1591177 times.
✓ Branch 1 taken 4460634 times.
6051811 if(current_item(itype_triforcepiece))
2450 {
2451 4460634 int32_t itemid =
2452
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2453 ? iTriforce
2454 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2455
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2456 4460634 tile+=itemsbuf[itemid].ltm;
2457 4460634 }
2458
2459
2/2
✓ Branch 0 taken 6051811 times.
✓ Branch 1 taken 3098527232 times.
3104579043 for(int32_t i=0; i<itype_max; i++)
2460 {
2461
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56075776 times.
3098527232 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2462 {
2463
2/2
✓ Branch 0 taken 1095230 times.
✓ Branch 1 taken 54980546 times.
56075776 switch(i)
2464 {
2465 case itype_bomb:
2466 case itype_sbomb:
2467 case itype_clock:
2468 case itype_key:
2469 case itype_lkey:
2470 case itype_map:
2471 case itype_compass:
2472 case itype_bosskey:
2473 case itype_magiccontainer:
2474 case itype_triforcepiece:
2475 1095230 continue; //already handled
2476 }
2477 54980546 }
2478 3097432002 int32_t itemid = current_item_id(i,false);
2479
2/2
✓ Branch 0 taken 3091380191 times.
✓ Branch 1 taken 6051811 times.
3097432002 if(i == itype_shield)
2480 6051811 itemid = getCurrentShield(false);
2481
2482
4/4
✓ Branch 0 taken 80852133 times.
✓ Branch 1 taken 3016579869 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80751152 times.
3097432002 if(itemid < 0 || !checkbunny(itemid))
2483 3016680850 continue;
2484
2485 80751152 itemdata const& itm = itemsbuf[itemid];
2486
2487
2/2
✓ Branch 0 taken 75336675 times.
✓ Branch 1 taken 5414477 times.
80751152 switch(itm.family)
2488 {
2489 case itype_shield:
2490
1/2
✓ Branch 0 taken 5414477 times.
✗ Branch 1 not taken.
5414477 if(itm.flags & ITEM_FLAG9) //active shield
2491 {
2492 if(!usingActiveShield(itemid))
2493 {
2494 tile+=itm.misc6; //'Inactive PTM'
2495 continue;
2496 }
2497 }
2498 5414477 break;
2499 }
2500
2501 80751152 tile+=itm.ltm;
2502 80751152 }
2503
2504 6051811 return tile;
2505 }
2506
2507 6051811 int32_t bunny_tile_mod()
2508 {
2509
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6049941 times.
6051811 if(Hero.BunnyClock())
2510 {
2511 1870 return game->get_bunny_ltm();
2512 }
2513 6049941 return 0;
2514 6051811 }
2515
2516 // Hints are drawn on a separate layer to combo reveals.
2517 16332 void draw_lens_under(BITMAP *dest, bool layer)
2518 {
2519 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2520 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2521 //Lens flag 3: Don't show armos/chest/dive items
2522 //Lens flag 4: Show Raft Paths
2523 //Lens flag 5: Show Invisible Enemies
2524
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2525
2526 16332 int32_t strike_hint_table[11]=
2527 {
2528 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2529 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2530 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2531 };
2532
2533 // int32_t page = tmpscr->cpage;
2534 {
2535 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2536 // int32_t temptimer=0;
2537 16332 int32_t tempitem, tempweapon=0;
2538 16332 strike_hint=strike_hint_table[strike_hint_counter];
2539
2540
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2541 {
2542 490 strike_hint_timer=0;
2543 490 strike_hint_counter=((strike_hint_counter+1)%11);
2544 490 }
2545
2546 16332 ++strike_hint_timer;
2547
2548
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2549 {
2550 2874432 int32_t x = (i & 15) << 4;
2551 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2552 2874432 int32_t tempitemx=-16, tempitemy=-16;
2553 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2554
2555
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2556 {
2557 5748864 int32_t checkflag=0;
2558
2559
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2560 {
2561 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2562 2874432 }
2563 else
2564 {
2565 2874432 checkflag=tmpscr->sflag[i];
2566 }
2567
2568
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2569 {
2570
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2571 {
2572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2573 906 }
2574 else
2575 {
2576 192 checkflag = strike_hint;
2577 }
2578 1098 }
2579
2580
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2581 {
2582 case 0:
2583 case mfZELDA:
2584 case mfPUSHED:
2585 case mfENEMY0:
2586 case mfENEMY1:
2587 case mfENEMY2:
2588 case mfENEMY3:
2589 case mfENEMY4:
2590 case mfENEMY5:
2591 case mfENEMY6:
2592 case mfENEMY7:
2593 case mfENEMY8:
2594 case mfENEMY9:
2595 case mfSINGLE:
2596 case mfSINGLE16:
2597 case mfNOENEMY:
2598 case mfTRAP_H:
2599 case mfTRAP_V:
2600 case mfTRAP_4:
2601 case mfTRAP_LR:
2602 case mfTRAP_UD:
2603 case mfNOGROUNDENEMY:
2604 case mfNOBLOCKS:
2605 case mfSCRIPT1:
2606 case mfSCRIPT2:
2607 case mfSCRIPT3:
2608 case mfSCRIPT4:
2609 case mfSCRIPT5:
2610 case mfSCRIPT6:
2611 case mfSCRIPT7:
2612 case mfSCRIPT8:
2613 case mfSCRIPT9:
2614 case mfSCRIPT10:
2615 case mfSCRIPT11:
2616 case mfSCRIPT12:
2617 case mfSCRIPT13:
2618 case mfSCRIPT14:
2619 case mfSCRIPT15:
2620 case mfSCRIPT16:
2621 case mfSCRIPT17:
2622 case mfSCRIPT18:
2623 case mfSCRIPT19:
2624 case mfSCRIPT20:
2625 case mfPITHOLE:
2626 case mfPITFALLFLOOR:
2627 case mfLAVA:
2628 case mfICE:
2629 case mfICEDAMAGE:
2630 case mfDAMAGE1:
2631 case mfDAMAGE2:
2632 case mfDAMAGE4:
2633 case mfDAMAGE8:
2634 case mfDAMAGE16:
2635 case mfDAMAGE32:
2636 case mfFREEZEALL:
2637 case mfFREZEALLANSFFCS:
2638 case mfFREEZEFFCSOLY:
2639 case mfSCRITPTW1TRIG:
2640 case mfSCRITPTW2TRIG:
2641 case mfSCRITPTW3TRIG:
2642 case mfSCRITPTW4TRIG:
2643 case mfSCRITPTW5TRIG:
2644 case mfSCRITPTW6TRIG:
2645 case mfSCRITPTW7TRIG:
2646 case mfSCRITPTW8TRIG:
2647 case mfSCRITPTW9TRIG:
2648 case mfSCRITPTW10TRIG:
2649 case mfTROWEL:
2650 case mfTROWELNEXT:
2651 case mfTROWELSPECIALITEM:
2652 case mfSLASHPOT:
2653 case mfLIFTPOT:
2654 case mfLIFTORSLASH:
2655 case mfLIFTROCK:
2656 case mfLIFTROCKHEAVY:
2657 case mfDROPITEM:
2658 case mfSPECIALITEM:
2659 case mfDROPKEY:
2660 case mfDROPLKEY:
2661 case mfDROPCOMPASS:
2662 case mfDROPMAP:
2663 case mfDROPBOSSKEY:
2664 case mfSPAWNNPC:
2665 case mfSWITCHHOOK:
2666 case mfSIDEVIEWLADDER:
2667 case mfSIDEVIEWPLATFORM:
2668 case mfNOENEMYSPAWN:
2669 case mfENEMYALL:
2670 case mfNOMIRROR:
2671 case mfUNSAFEGROUND:
2672 case mf168:
2673 case mf169:
2674 case mf170:
2675 case mf171:
2676 case mf172:
2677 case mf173:
2678 case mf174:
2679 case mf175:
2680 case mf176:
2681 case mf177:
2682 case mf178:
2683 case mf179:
2684 case mf180:
2685 case mf181:
2686 case mf182:
2687 case mf183:
2688 case mf184:
2689 case mf185:
2690 case mf186:
2691 case mf187:
2692 case mf188:
2693 case mf189:
2694 case mf190:
2695 case mf191:
2696 case mf192:
2697 case mf193:
2698 case mf194:
2699 case mf195:
2700 case mf196:
2701 case mf197:
2702 case mf198:
2703 case mf199:
2704 case mf200:
2705 case mf201:
2706 case mf202:
2707 case mf203:
2708 case mf204:
2709 case mf205:
2710 case mf206:
2711 case mf207:
2712 case mf208:
2713 case mf209:
2714 case mf210:
2715 case mf211:
2716 case mf212:
2717 case mf213:
2718 case mf214:
2719 case mf215:
2720 case mf216:
2721 case mf217:
2722 case mf218:
2723 case mf219:
2724 case mf220:
2725 case mf221:
2726 case mf222:
2727 case mf223:
2728 case mf224:
2729 case mf225:
2730 case mf226:
2731 case mf227:
2732 case mf228:
2733 case mf229:
2734 case mf230:
2735 case mf231:
2736 case mf232:
2737 case mf233:
2738 case mf234:
2739 case mf235:
2740 case mf236:
2741 case mf237:
2742 case mf238:
2743 case mf239:
2744 case mf240:
2745 case mf241:
2746 case mf242:
2747 case mf243:
2748 case mf244:
2749 case mf245:
2750 case mf246:
2751 case mf247:
2752 case mf248:
2753 case mf249:
2754 case mf250:
2755 case mf251:
2756 case mf252:
2757 case mf253:
2758 case mf254:
2759 case mfEXTENDED:
2760 5706470 break;
2761
2762 case mfPUSHUD:
2763 case mfPUSHLR:
2764 case mfPUSH4:
2765 case mfPUSHU:
2766 case mfPUSHD:
2767 case mfPUSHL:
2768 case mfPUSHR:
2769 case mfPUSHUDNS:
2770 case mfPUSHLRNS:
2771 case mfPUSH4NS:
2772 case mfPUSHUNS:
2773 case mfPUSHDNS:
2774 case mfPUSHLNS:
2775 case mfPUSHRNS:
2776 case mfPUSHUDINS:
2777 case mfPUSHLRINS:
2778 case mfPUSH4INS:
2779 case mfPUSHUINS:
2780 case mfPUSHDINS:
2781 case mfPUSHLINS:
2782 case mfPUSHRINS:
2783
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2784
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2785 {
2786 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2787 }
2788
2789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2790
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2791 {
2792
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2793 {
2794
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2795 {
2796 case cPUSH_HEAVY:
2797 case cPUSH_HW:
2798 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2799 72 tempitemx=x, tempitemy=y;
2800
2801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2802 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2803
2804 72 break;
2805
2806 case cPUSH_HEAVY2:
2807 case cPUSH_HW2:
2808 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2809 63 tempitemx=x, tempitemy=y;
2810
2811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2812 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2813
2814 63 break;
2815 }
2816 1032 }
2817 2438 }
2818
2819 3148 break;
2820
2821 case mfWHISTLE:
2822
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2823 {
2824 tempitem=getItemID(itemsbuf,itype_whistle,1);
2825
2826 if(tempitem<0) break;
2827
2828 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2830 {
2831 tempitemx=x;
2832 tempitemy=y;
2833 }
2834
2835 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2836 }
2837
2838 2418 break;
2839
2840 //Why is this here?
2841 case mfFAIRY:
2842 case mfMAGICFAIRY:
2843 case mfALLFAIRY:
2844 if(hints)
2845 {
2846 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2847
2848 if(tempitem < 0) break;
2849
2850 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2851 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2852 {
2853 tempitemx=x;
2854 tempitemy=y;
2855 }
2856
2857 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2858 }
2859
2860 break;
2861
2862 case mfANYFIRE:
2863
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2864 {
2865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2866 252 }
2867 else
2868 {
2869 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2870
2871
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2872
2873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2874
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2875 {
2876 189 tempitemx=x;
2877 189 tempitemy=y;
2878 189 }
2879
2880 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2881 }
2882
2883 504 break;
2884
2885 case mfSTRONGFIRE:
2886 if(!hints)
2887 {
2888 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2889 }
2890 else
2891 {
2892 tempitem=getItemID(itemsbuf,itype_candle,2);
2893
2894 if(tempitem<0) break;
2895
2896 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2897 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2898 {
2899 tempitemx=x;
2900 tempitemy=y;
2901 }
2902
2903 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2904 }
2905
2906 break;
2907
2908 case mfMAGICFIRE:
2909 if(!hints)
2910 {
2911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2912 }
2913 else
2914 {
2915 tempitem=getItemID(itemsbuf,itype_wand,1);
2916
2917 if(tempitem<0) break;
2918
2919 tempweapon=wFire;
2920
2921 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2922 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2923 {
2924 tempitemx=x;
2925 tempitemy=y;
2926 }
2927 else
2928 {
2929 tempweaponx=x;
2930 tempweapony=y;
2931 }
2932
2933 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2934 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2935 }
2936
2937 break;
2938
2939 case mfDIVINEFIRE:
2940 if(!hints)
2941 {
2942 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2943 }
2944 else
2945 {
2946 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2947
2948 if(tempitem<0) break;
2949
2950 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2951 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2952 {
2953 tempitemx=x;
2954 tempitemy=y;
2955 }
2956
2957 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2958 }
2959
2960 break;
2961
2962 case mfARROW:
2963
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2964 {
2965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2966 732 }
2967 else
2968 {
2969 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2970
2971
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2972
2973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2974
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2975 {
2976 61 tempitemx=x;
2977 61 tempitemy=y;
2978 61 }
2979
2980 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2981 }
2982
2983 814 break;
2984
2985 case mfSARROW:
2986 if(!hints)
2987 {
2988 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2989 }
2990 else
2991 {
2992 tempitem=getItemID(itemsbuf,itype_arrow,2);
2993
2994 if(tempitem<0) break;
2995
2996 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2997 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2998 {
2999 tempitemx=x;
3000 tempitemy=y;
3001 }
3002
3003 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3004 }
3005
3006 break;
3007
3008 case mfGARROW:
3009 if(!hints)
3010 {
3011 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3012 }
3013 else
3014 {
3015 tempitem=getItemID(itemsbuf,itype_arrow,3);
3016
3017 if(tempitem<0) break;
3018
3019 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3020 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3021 {
3022 tempitemx=x;
3023 tempitemy=y;
3024 }
3025
3026 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3027 }
3028
3029 break;
3030
3031 case mfBOMB:
3032
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3033 {
3034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3035 16 }
3036 else
3037 {
3038 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3039 17 tempweapon = wLitBomb;
3040
3041 //if (tempitem<0) break;
3042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3043
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3044 {
3045 12 tempweaponx=x;
3046 12 tempweapony=y;
3047 12 }
3048
3049 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3050 }
3051
3052 33 break;
3053
3054 case mfSBOMB:
3055
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3056 {
3057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3058 48 }
3059 else
3060 {
3061 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3062 //if (tempitem<0) break;
3063 48 tempweapon = wLitSBomb;
3064
3065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3066
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3067 {
3068 36 tempweaponx=x;
3069 36 tempweapony=y;
3070 36 }
3071
3072 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3073 }
3074
3075 96 break;
3076
3077 case mfARMOS_SECRET:
3078
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3079 {
3080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3081 12 }
3082 24 break;
3083
3084 case mfBRANG:
3085
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3086 {
3087 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3088 }
3089 else
3090 {
3091 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3092
3093
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3094
3095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3096
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3097 {
3098 4 tempitemx=x;
3099 4 tempitemy=y;
3100 4 }
3101
3102 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3103 }
3104
3105 5 break;
3106
3107 case mfMBRANG:
3108 if(!hints)
3109 {
3110 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3111 }
3112 else
3113 {
3114 tempitem=getItemID(itemsbuf,itype_brang,2);
3115
3116 if(tempitem<0) break;
3117
3118 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3119 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3120 {
3121 tempitemx=x;
3122 tempitemy=y;
3123 }
3124
3125 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3126 }
3127
3128 break;
3129
3130 case mfFBRANG:
3131 if(!hints)
3132 {
3133 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3134 }
3135 else
3136 {
3137 tempitem=getItemID(itemsbuf,itype_brang,3);
3138
3139 if(tempitem<0) break;
3140
3141 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3142 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3143 {
3144 tempitemx=x;
3145 tempitemy=y;
3146 }
3147
3148 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3149 }
3150
3151 break;
3152
3153 case mfWANDMAGIC:
3154 if(!hints)
3155 {
3156 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3157 }
3158 else
3159 {
3160 tempitem=getItemID(itemsbuf,itype_wand,1);
3161
3162 if(tempitem<0) break;
3163
3164 tempweapon=itemsbuf[tempitem].wpn3;
3165
3166 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3167 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3168 {
3169 tempitemx=x;
3170 tempitemy=y;
3171 }
3172 else
3173 {
3174 tempweaponx=x;
3175 tempweapony=y;
3176 --lens_hint_weapon[wMagic][4];
3177
3178 if(lens_hint_weapon[wMagic][4]<-8)
3179 {
3180 lens_hint_weapon[wMagic][4]=8;
3181 }
3182 }
3183
3184 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3185 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3186 }
3187
3188 break;
3189
3190 case mfREFMAGIC:
3191
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3192 {
3193 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3194 }
3195 else
3196 {
3197 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3198
3199
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3200
3201 16 tempweapon=ewMagic;
3202
3203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3204
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3205 {
3206 13 tempitemx=x;
3207 13 tempitemy=y;
3208 13 }
3209 else
3210 {
3211 3 tempweaponx=x;
3212 3 tempweapony=y;
3213
3214
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3215 {
3216 1 --lens_hint_weapon[ewMagic][4];
3217 1 }
3218 else
3219 {
3220 2 ++lens_hint_weapon[ewMagic][4];
3221 }
3222
3223
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3224 {
3225 lens_hint_weapon[ewMagic][2]=up;
3226 }
3227
3228
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3229 {
3230 2 lens_hint_weapon[ewMagic][2]=down;
3231 2 }
3232 }
3233
3234 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3235 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3236 }
3237
3238 16 break;
3239
3240 case mfREFFIREBALL:
3241
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3242 {
3243 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3244 }
3245 else
3246 {
3247 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3248
3249
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3250
3251 16 tempweapon=ewFireball;
3252
3253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3254
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3255 {
3256 12 tempitemx=x;
3257 12 tempitemy=y;
3258 12 tempweaponx=x;
3259 12 tempweapony=y;
3260 12 ++lens_hint_weapon[ewFireball][3];
3261
3262
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3263 {
3264 1 lens_hint_weapon[ewFireball][3]=-8;
3265 1 lens_hint_weapon[ewFireball][4]=8;
3266 1 }
3267
3268
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3269 {
3270 8 ++lens_hint_weapon[ewFireball][4];
3271 8 }
3272 else
3273 {
3274 4 --lens_hint_weapon[ewFireball][4];
3275 }
3276 12 }
3277
3278 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3279 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3280 }
3281
3282 16 break;
3283
3284 case mfSWORD:
3285
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3286 {
3287 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3288 }
3289 else
3290 {
3291 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3292
3293
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3294
3295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3296
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3297 {
3298 5 tempitemx=x;
3299 5 tempitemy=y;
3300 5 }
3301
3302 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3303 }
3304
3305 7 break;
3306
3307 case mfWSWORD:
3308 if(!hints)
3309 {
3310 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3311 }
3312 else
3313 {
3314 tempitem=getItemID(itemsbuf,itype_sword,2);
3315
3316 if(tempitem<0) break;
3317
3318 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3320 {
3321 tempitemx=x;
3322 tempitemy=y;
3323 }
3324
3325 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3326 }
3327
3328 break;
3329
3330 case mfMSWORD:
3331 if(!hints)
3332 {
3333 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3334 }
3335 else
3336 {
3337 tempitem=getItemID(itemsbuf,itype_sword,3);
3338
3339 if(tempitem<0) break;
3340
3341 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3342 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3343 {
3344 tempitemx=x;
3345 tempitemy=y;
3346 }
3347
3348 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3349 }
3350
3351 break;
3352
3353 case mfXSWORD:
3354 if(!hints)
3355 {
3356 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3357 }
3358 else
3359 {
3360 tempitem=getItemID(itemsbuf,itype_sword,4);
3361
3362 if(tempitem<0) break;
3363
3364 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3365 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3366 {
3367 tempitemx=x;
3368 tempitemy=y;
3369 }
3370
3371 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3372 }
3373
3374 break;
3375
3376 case mfSWORDBEAM:
3377
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3378 {
3379 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3380 }
3381 else
3382 {
3383 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3384
3385
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3386
3387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3388
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3389 {
3390 11 tempitemx=x;
3391 11 tempitemy=y;
3392 11 }
3393
3394 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3395 }
3396
3397 16 break;
3398
3399 case mfWSWORDBEAM:
3400 if(!hints)
3401 {
3402 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3403 }
3404 else
3405 {
3406 tempitem=getItemID(itemsbuf,itype_sword,2);
3407
3408 if(tempitem<0) break;
3409
3410 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3411 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3412 {
3413 tempitemx=x;
3414 tempitemy=y;
3415 }
3416
3417 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3418 }
3419
3420 break;
3421
3422 case mfMSWORDBEAM:
3423 if(!hints)
3424 {
3425 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3426 }
3427 else
3428 {
3429 tempitem=getItemID(itemsbuf,itype_sword,3);
3430
3431 if(tempitem<0) break;
3432
3433 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3434 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3435 {
3436 tempitemx=x;
3437 tempitemy=y;
3438 }
3439
3440 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3441 }
3442
3443 break;
3444
3445 case mfXSWORDBEAM:
3446 if(!hints)
3447 {
3448 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3449 }
3450 else
3451 {
3452 tempitem=getItemID(itemsbuf,itype_sword,4);
3453
3454 if(tempitem<0) break;
3455
3456 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3457 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3458 {
3459 tempitemx=x;
3460 tempitemy=y;
3461 }
3462
3463 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3464 }
3465
3466 break;
3467
3468 case mfHOOKSHOT:
3469
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3470 {
3471 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3472 }
3473 else
3474 {
3475 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3476
3477
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3478
3479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3480
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3481 {
3482 12 tempitemx=x;
3483 12 tempitemy=y;
3484 12 }
3485
3486 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3487 }
3488
3489 17 break;
3490
3491 case mfWAND:
3492
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3493 {
3494 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3495 }
3496 else
3497 {
3498 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3499
3500
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3501
3502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3503
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3504 {
3505 28 tempitemx=x;
3506 28 tempitemy=y;
3507 28 }
3508
3509 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3510 }
3511
3512 35 break;
3513
3514 case mfHAMMER:
3515
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3516 {
3517 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3518 }
3519 else
3520 {
3521 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3522
3523
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3524
3525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3526
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3527 {
3528 13 tempitemx=x;
3529 13 tempitemy=y;
3530 13 }
3531
3532 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3533 }
3534
3535 17 break;
3536
3537 case mfARMOS_ITEM:
3538 case mfDIVE_ITEM:
3539
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3540 {
3541 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3542 2064 }
3543 2064 break;
3544
3545 case 16:
3546 case 17:
3547 case 18:
3548 case 19:
3549 case 20:
3550 case 21:
3551 case 22:
3552 case 23:
3553 case 24:
3554 case 25:
3555 case 26:
3556 case 27:
3557 case 28:
3558 case 29:
3559 case 30:
3560 case 31:
3561
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3563 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3564
3565 3618 break;
3566 case mfSECRETSNEXT:
3567 if(!hints)
3568 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3569 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3570
3571 break;
3572
3573 case mfSTRIKE:
3574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3575 {
3576 906 goto special;
3577 }
3578 else
3579 {
3580 break;
3581 }
3582
3583 28640 default: goto special;
3584
3585 special:
3586
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3587 {
3588
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3589 {
3590 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3591 4913 }
3592 6549 }
3593
3594 29546 break;
3595 }
3596 5748864 }
3597 2874432 }
3598
3599
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3600 {
3601
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3602 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3603
3604
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3605 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3606
3607
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3608 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3609
3610
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3611 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3612
3613
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3614 {
3615 43 showbombeddoor(dest, 0);
3616 43 }
3617
3618
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3619 {
3620 39 showbombeddoor(dest, 1);
3621 39 }
3622
3623
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3624 {
3625 showbombeddoor(dest, 2);
3626 }
3627
3628
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3629 {
3630 37 showbombeddoor(dest, 3);
3631 37 }
3632 8166 }
3633
3634
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3635 {
3636
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3637 {
3638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3639 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3640 1123 }
3641 else
3642 {
3643
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3644 {
3645 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3646 48 int32_t tempitemx=-16;
3647 48 int32_t tempitemy=-16;
3648
3649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3650
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3651 {
3652 24 tempitemx=tmpscr->stairx;
3653 24 tempitemy=tmpscr->stairy+playing_field_offset;
3654 24 }
3655
3656 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3657 48 }
3658 }
3659 2034 }
3660 }
3661 16332 }
3662
3663 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3664
3665 7997 void draw_lens_over()
3666 {
3667 // Oh, what the heck.
3668 static BITMAP *lens_scr = NULL;
3669 static int32_t last_width = -1;
3670 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3671
3672 // Only redraw the circle if the size has changed
3673
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3674 {
3675
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3676 {
3677 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3678 10 }
3679
3680 10 clear_to_color(lens_scr, BLACK);
3681 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3682 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3683 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3684 10 last_width=width;
3685 10 }
3686
3687 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3688 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3689 7997 }
3690
3691 //----------------------------------------------------------------
3692
3693 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3694 {
3695 //recreating a big bitmap every frame is highly sluggish.
3696
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3697 31111 clear_to_color(wavebuf, BLACK);
3698 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3699
3700 int32_t ofs;
3701 // int32_t amplitude=8;
3702 // int32_t wavelength=4;
3703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3704
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3705 31111 int32_t amp2=168;
3706
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3707 31111 int32_t i=frame%amp2;
3708
3709
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3710 {
3711
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3712 {
3713 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3714 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3715 }
3716 else
3717 {
3718 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3719 }
3720
3721
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3722 {
3723
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3724 {
3725 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3726 1338021888 }
3727 5226648 }
3728 5226648 }
3729 31111 }
3730
3731 4848 void draw_fuzzy(int32_t fuzz)
3732 // draws from right half of scrollbuf to framebuf
3733 {
3734 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3735 byte *start, *si, *di;
3736
3737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3738 fuzz = 1;
3739
3740 4848 xstep = 128%fuzz;
3741
3742
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3743 3838 xstep = fuzz-xstep;
3744
3745 4848 ystep = 112%fuzz;
3746
3747
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3748 3434 ystep = fuzz-ystep;
3749
3750 4848 firsty = 1;
3751
3752
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3753 {
3754 174932 start = &(scrollbuf->line[y][256]);
3755
3756
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3757 {
3758 1085952 si = start;
3759 1085952 di = &(framebuf->line[y+dy][0]);
3760 1085952 i = xstep;
3761 1085952 firstx = 1;
3762
3763
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3764 {
3765 278003712 *(di++) = *si;
3766
3767
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3768 {
3769
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3770 42668864 si += fuzz;
3771 else
3772 {
3773 1085952 si += fuzz-xstep;
3774 1085952 firstx = 0;
3775 }
3776
3777 43754816 i = 0;
3778 43754816 }
3779 278003712 }
3780 1085952 }
3781
3782
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3783 170084 y += fuzz;
3784 else
3785 {
3786 4848 y += ystep;
3787 4848 ystep = fuzz;
3788 4848 firsty = 0;
3789 }
3790 }
3791 4848 }
3792
3793 9285079 void updatescr(bool allowwavy)
3794 {
3795
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9284963 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9285079 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3796
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9284963 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
9285079 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3797
3798
2/2
✓ Branch 0 taken 9258314 times.
✓ Branch 1 taken 26765 times.
9285079 if(toogam)
3799 {
3800 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3801 26765 }
3802
3803
1/2
✓ Branch 0 taken 9285079 times.
✗ Branch 1 not taken.
9285079 if(Showpal)
3804 dump_pal(framebuf);
3805
3806
2/2
✓ Branch 0 taken 8984016 times.
✓ Branch 1 taken 301063 times.
9285079 if(!Playing)
3807 301063 black_opening_count=0;
3808
3809
2/2
✓ Branch 0 taken 9211819 times.
✓ Branch 1 taken 73260 times.
9285079 if(black_opening_count<0) //shape is opening up
3810 {
3811 73260 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3812
3813
2/4
✓ Branch 0 taken 73260 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73260 times.
73260 if(Advance||(!Paused))
3814 {
3815 73260 ++black_opening_count;
3816 73260 }
3817 73260 }
3818
2/2
✓ Branch 0 taken 9185683 times.
✓ Branch 1 taken 26136 times.
9211819 else if(black_opening_count>0) //shape is closing
3819 {
3820 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3821
3822
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3823 {
3824 26136 --black_opening_count;
3825 26136 }
3826 26136 }
3827
3828
3/4
✓ Branch 0 taken 9187189 times.
✓ Branch 1 taken 97890 times.
✓ Branch 2 taken 9187189 times.
✗ Branch 3 not taken.
9285079 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3829 {
3830 black_opening_shape = bosCIRCLE;
3831 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3832 refreshTints();
3833 refreshpal=true;
3834 }
3835
3836
2/2
✓ Branch 0 taken 9030880 times.
✓ Branch 1 taken 254199 times.
9285079 if(refreshpal)
3837 {
3838 254199 refreshpal=false;
3839 254199 RAMpal[253] = _RGB(0,0,0);
3840 254199 RAMpal[254] = _RGB(63,63,63);
3841 254199 hw_palette = &RAMpal;
3842 254199 update_hw_pal = true;
3843
3844 254199 create_rgb_table(&rgb_table, RAMpal, NULL);
3845 254199 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3846 254199 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3847
3848
2/2
✓ Branch 0 taken 65074944 times.
✓ Branch 1 taken 254199 times.
65329143 for(int32_t q=0; q<PAL_SIZE; q++)
3849 {
3850 65074944 trans_table2.data[0][q] = q;
3851 65074944 trans_table2.data[q][q] = q;
3852 65074944 }
3853 254199 }
3854
3855 9285079 bool clearwavy = (wavy <= 0);
3856
3857
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9277424 times.
9285079 if(wavy <= 0)
3858 {
3859 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3860 9277424 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3861 9277424 }
3862
3863 9285079 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3864
3865
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9253718 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9285079 if(wavy && Playing && allowwavy)
3866 {
3867 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3868 31111 }
3869
3870
2/2
✓ Branch 0 taken 9277424 times.
✓ Branch 1 taken 7655 times.
9285079 if(clearwavy)
3871 9277424 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3872
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3873 7655 wavy--; // Wavy was set by a script. Decrement it.
3874
3875
5/6
✓ Branch 0 taken 8984016 times.
✓ Branch 1 taken 301063 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8724442 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9285079 if(Playing && msgpos && !screenscrolling)
3876 {
3877
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3878 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3879
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3880 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3881
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3882 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3883 259574 }
3884
3885 /*
3886 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3887 {
3888 BITMAP* subBmp = 0;
3889 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3890 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3891 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3892 destroy_bitmap(subBmp);
3893 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3894 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3895 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3896 }
3897 */
3898
3899
2/2
✓ Branch 0 taken 9244022 times.
✓ Branch 1 taken 41057 times.
9285079 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3900
3901
2/2
✓ Branch 0 taken 9248647 times.
✓ Branch 1 taken 36432 times.
9285079 if(nosubscr)
3902 {
3903 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3904 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3905 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3906 36432 }
3907
3908 //TODO: Optimize blit 'overcalls' -Gleeok
3909
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9248647 times.
9285079 BITMAP *source = nosubscr ? panorama : wavybuf;
3910 9285079 blit(source,framebuf,0,0,0,0,256,224);
3911
3912 9285079 update_hw_screen();
3913 9285079 }
3914
3915 //----------------------------------------------------------------
3916
3917 static PALETTE syspal;
3918 int32_t onGUISnapshot()
3919 {
3920 char buf[200];
3921 int32_t num=0;
3922 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3923 do
3924 {
3925 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3926 }
3927 while(num<99999 && exists(buf));
3928
3929 BITMAP *b = create_bitmap_ex(8,resx,resy);
3930
3931 if(b)
3932 {
3933 blit(screen,b,0,0,0,0,resx,resy);
3934 save_bitmap(buf,b,RAMpal);
3935 destroy_bitmap(b);
3936 }
3937
3938 return D_O_K;
3939 }
3940
3941 int32_t onNonGUISnapshot()
3942 {
3943 PALETTE temppal;
3944 get_palette(temppal);
3945 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3946
3947 char buf[200];
3948 int32_t num=0;
3949
3950 do
3951 {
3952 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3953 }
3954 while(num<99999 && exists(buf));
3955
3956 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3957
3958 return D_O_K;
3959 }
3960
3961 int32_t onSnapshot()
3962 {
3963 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3964 {
3965 onGUISnapshot();
3966 }
3967 else
3968 {
3969 onNonGUISnapshot();
3970 }
3971
3972 return D_O_K;
3973 }
3974
3975 int32_t onSaveMapPic()
3976 {
3977 int32_t mapres2 = 0;
3978 char buf[200];
3979 int32_t num=0;
3980 mapscr tmpscr_b[2];
3981 mapscr tmpscr_c[6];
3982 BITMAP* _screen_draw_buffer = NULL;
3983 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3984 set_clip_state(_screen_draw_buffer,1);
3985
3986 for(int32_t i=0; i<6; ++i)
3987 {
3988 tmpscr_c[i] = tmpscr2[i];
3989 tmpscr2[i].zero_memory();
3990
3991 if(i>=2)
3992 {
3993 continue;
3994 }
3995
3996 tmpscr_b[i] = tmpscr[i];
3997 tmpscr[i].zero_memory();
3998 }
3999
4000 do
4001 {
4002 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4003 }
4004 while(num<99999 && exists(buf));
4005
4006 BITMAP* mappic = NULL;
4007
4008
4009 bool done=false, redraw=true;
4010
4011 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4012
4013 if(!mappic)
4014 {
4015 enter_sys_pal();
4016 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4017 exit_sys_pal();
4018 return D_O_K;;
4019 }
4020
4021 // draw the map
4022 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4023
4024 for(int32_t y=0; y<8; y++)
4025 {
4026 for(int32_t x=0; x<16; x++)
4027 {
4028 if(!displayOnMap(x, y))
4029 {
4030 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4031 }
4032 else
4033 {
4034 int32_t s = (y<<4) + x;
4035 loadscr2(1,s,-1);
4036
4037 for(int32_t i=0; i<6; i++)
4038 {
4039 if(tmpscr[1].layermap[i]<=0)
4040 continue;
4041
4042 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4043 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4044 {
4045 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4046
4047 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4048 }
4049 }
4050
4051 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4052
4053 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4054
4055 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4056 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4061 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4062 {
4063 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4064 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4065 {
4066 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4067 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4068 }
4069 }
4070 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4071
4072 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4073
4074 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4075 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4076 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4077 {
4078 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4079 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4080 }
4081 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4082 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4083
4084 }
4085
4086 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4087 }
4088 }
4089
4090 for(int32_t i=0; i<6; ++i)
4091 {
4092 tmpscr2[i]=tmpscr_c[i];
4093
4094 if(i>=2)
4095 {
4096 continue;
4097 }
4098
4099 tmpscr[i]=tmpscr_b[i];
4100 }
4101
4102 save_bitmap(buf,mappic,RAMpal);
4103 destroy_bitmap(mappic);
4104 destroy_bitmap(_screen_draw_buffer);
4105 return D_O_K;
4106 }
4107
4108 13 void f_Quit(int32_t type)
4109 {
4110
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4111 return;
4112
4113 13 bool from_menu = is_sys_pal;
4114
4115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4116 {
4117 13 music_pause();
4118 13 pause_all_sfx();
4119 13 sys_mouse();
4120 13 }
4121 13 enter_sys_pal();
4122 13 clear_keybuf();
4123
4124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_version_check(0, 10))
4125 13 replay_poll();
4126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4127 13 replay_peek_quit();
4128
4129
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4130 switch(type)
4131 {
4132 case qQUIT:
4133 onQuit();
4134 break;
4135
4136 case qRESET:
4137 onReset();
4138 break;
4139
4140 case qEXIT:
4141 onExit();
4142 break;
4143 }
4144
4145
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4146 {
4147 13 kill_sfx();
4148 13 music_stop();
4149 13 exit_sys_pal();
4150 13 update_hw_screen();
4151 13 }
4152 else
4153 {
4154 exit_sys_pal();
4155 if(!from_menu)
4156 {
4157 music_resume();
4158 resume_all_sfx();
4159 }
4160 }
4161
4162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4163 13 game_mouse();
4164 13 eat_buttons();
4165
4166 13 zc_readrawkey(KEY_ESC);
4167
4168 13 zc_readrawkey(KEY_ENTER);
4169 13 }
4170
4171 //----------------------------------------------------------------
4172
4173 int32_t onNoWalls()
4174 {
4175 cheats_enqueue(Cheat::Walls);
4176 return D_O_K;
4177 }
4178
4179 int32_t onIgnoreSideview()
4180 {
4181 cheats_enqueue(Cheat::IgnoreSideView);
4182 return D_O_K;
4183 }
4184
4185 9284954 int32_t input_idle(bool checkmouse)
4186 {
4187 static int32_t mx, my, mz, mb;
4188
4189
4/6
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461268 times.
✓ Branch 3 taken 6823686 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461268 times.
11746222 if(keypressed() || zc_key_pressed() ||
4190
4/8
✓ Branch 0 taken 2461268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461268 times.
✗ Branch 7 not taken.
2461268 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4191 {
4192 6823686 idle_count = 0;
4193
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823686 times.
6823686 if(active_count < MAX_ACTIVE)
4195 {
4196 6823686 ++active_count;
4197 6823686 }
4198 6823686 }
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461268 times.
2461268 else if(idle_count < MAX_IDLE)
4200 {
4201 2461268 ++idle_count;
4202 2461268 active_count = 0;
4203 2461268 }
4204
4205 9284954 mx = mouse_x;
4206 9284954 my = mouse_y;
4207 9284954 mz = mouse_z;
4208 9284954 mb = mouse_b;
4209
4210 9284954 return idle_count;
4211 }
4212
4213 int32_t onGoFast()
4214 {
4215 cheats_enqueue(Cheat::Fast);
4216 return D_O_K;
4217 }
4218
4219 int32_t onKillCheat()
4220 {
4221 cheats_enqueue(Cheat::Kill);
4222 return D_O_K;
4223 }
4224
4225 int32_t onSecretsCheat()
4226 {
4227 cheats_enqueue(Cheat::TrigSecrets);
4228 return D_O_K;
4229 }
4230 int32_t onSecretsCheatPerm()
4231 {
4232 cheats_enqueue(Cheat::TrigSecretsPerm);
4233 return D_O_K;
4234 }
4235
4236 int32_t onShowLayer0()
4237 {
4238 show_layer_0 = !show_layer_0;
4239 return D_O_K;
4240 }
4241 int32_t onShowLayer1()
4242 {
4243 show_layer_1 = !show_layer_1;
4244 return D_O_K;
4245 }
4246 int32_t onShowLayer2()
4247 {
4248 show_layer_2 = !show_layer_2;
4249 return D_O_K;
4250 }
4251 int32_t onShowLayer3()
4252 {
4253 show_layer_3 = !show_layer_3;
4254 return D_O_K;
4255 }
4256 int32_t onShowLayer4()
4257 {
4258 show_layer_4 = !show_layer_4;
4259 return D_O_K;
4260 }
4261 int32_t onShowLayer5()
4262 {
4263 show_layer_5 = !show_layer_5;
4264 return D_O_K;
4265 }
4266 int32_t onShowLayer6()
4267 {
4268 show_layer_6 = !show_layer_6;
4269 return D_O_K;
4270 }
4271 int32_t onShowLayerO()
4272 {
4273 show_layer_over=!show_layer_over;
4274 return D_O_K;
4275 }
4276 int32_t onShowLayerP()
4277 {
4278 show_layer_push=!show_layer_push;
4279 return D_O_K;
4280 }
4281 int32_t onShowLayerS()
4282 {
4283 show_sprites=!show_sprites;
4284 return D_O_K;
4285 }
4286 int32_t onShowLayerF()
4287 {
4288 show_ffcs=!show_ffcs;
4289 return D_O_K;
4290 }
4291 int32_t onShowLayerW()
4292 {
4293 show_walkflags=!show_walkflags;
4294 if(show_walkflags)
4295 show_effectflags = false;
4296 return D_O_K;
4297 }
4298 int32_t onShowLayerE()
4299 {
4300 show_effectflags=!show_effectflags;
4301 if(show_effectflags)
4302 show_walkflags = false;
4303 return D_O_K;
4304 }
4305 int32_t onShowFFScripts()
4306 {
4307 show_ff_scripts=!show_ff_scripts;
4308 return D_O_K;
4309 }
4310 int32_t onShowHitboxes()
4311 {
4312 show_hitboxes=!show_hitboxes;
4313 return D_O_K;
4314 }
4315 int32_t onShowInfoOpacity()
4316 {
4317 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4318 zc_set_config("zc","debug_info_opacity",info_opacity);
4319 return D_O_K;
4320 }
4321
4322 int32_t onLightSwitch()
4323 {
4324 cheats_enqueue(Cheat::Light);
4325 return D_O_K;
4326 }
4327
4328 int32_t onGoTo();
4329 int32_t onGoToComplete();
4330
4331 9284954 void syskeys()
4332 {
4333 9284954 update_system_keys();
4334
4335 int32_t oldtitle_version;
4336
4337
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(close_button_quit)
4338 {
4339 close_button_quit=false;
4340 f_Quit(qEXIT);
4341 }
4342
4343 9284954 poll_joystick();
4344
4345
2/10
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9284954 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9284954 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4346 {
4347 oldtitle_version=title_version;
4348 System();
4349 }
4350
4351 9284954 mouse_down=gui_mouse_b();
4352
4353
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F1))
4354 {
4355 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4356 {
4357 halt=!halt;
4358 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4359 }
4360 else
4361 {
4362 Throttlefps=!Throttlefps;
4363 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4364 }
4365 }
4366
4367 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4368 /*
4369 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4370 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4371 */
4372
4373
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F2))
4374 {
4375 ShowFPS=!ShowFPS;
4376 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4377 }
4378
4379
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4380
4381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(zc_read_system_key(KEY_F4) && Playing)
4382 {
4383 Paused=true;
4384 Advance=true;
4385 }
4386
4387
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F6)) onTryQuit();
4388
4389 #ifndef ALLEGRO_MACOSX
4390
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4391
4392
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4393 #else
4394 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4395
4396 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4397 #endif
4398
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9284954 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4399
4400
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if (zc_read_system_key(KEY_F12))
4401 {
4402 onSnapshot();
4403 }
4404
4405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(debug_enabled && zc_read_system_key(KEY_TAB))
4406 set_debug(!get_debug());
4407
4408
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(CheatModifierKeys())
4409 {
4410 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4411 {
4412 if(!bindable_cheat(c))
4413 continue;
4414 if(get_debug() || cheat >= cheat_lvl(c))
4415 {
4416 if(checkcheat(c))
4417 cheats_hit_bind(c);
4418 }
4419 }
4420 }
4421
4422
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(volkeys)
4423 {
4424 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4425
4426 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4427
4428 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4429
4430 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4431 }
4432
4433
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9284954 if(!get_debug() || !SystemKeys || replay_is_replaying())
4434 9284954 goto bottom;
4435
4436 if(zc_readkey(KEY_D))
4437 {
4438 details = !details;
4439 rectfill(screen,0,0,319,7,BLACK);
4440 rectfill(screen,0,8,31,239,BLACK);
4441 rectfill(screen,288,8,319,239,BLACK);
4442 rectfill(screen,32,232,287,239,BLACK);
4443 }
4444
4445 if(zc_readkey(KEY_P)) Paused=!Paused;
4446
4447 //if(zc_readkey(KEY_P)) centerHero();
4448 if(zc_readkey(KEY_A))
4449 {
4450 Paused=true;
4451 Advance=true;
4452 }
4453
4454 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4455 #ifndef ALLEGRO_MACOSX
4456 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4457
4458 if(zc_readkey(KEY_F7))
4459 {
4460 Matrix(ss_speed, ss_density, 0);
4461 game_pal();
4462 }
4463 #else
4464 // The reason these are different on Mac in the first place is that
4465 // the OS doesn't let us use F9 and F10...
4466 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4467
4468 if(zc_readkey(KEY_F9))
4469 {
4470 Matrix(ss_speed, ss_density, 0);
4471 game_pal();
4472 }
4473 #endif
4474 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4475 {
4476 //change containers
4477 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4478 {
4479 //magic containers
4480 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4481 {
4482 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4483 }
4484 else
4485 {
4486 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4487 }
4488 }
4489 else
4490 {
4491 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4492 {
4493 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4494 }
4495 else
4496 {
4497 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4498 }
4499 }
4500 }
4501
4502 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4503 {
4504 //change containers
4505 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4506 {
4507 //magic containers
4508 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4509 {
4510 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4511 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4512 //heart containers
4513 }
4514 else
4515 {
4516 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4517 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4518 }
4519 }
4520 else
4521 {
4522 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4523 {
4524 game->set_magic(zc_max(game->get_magic()-1,0));
4525 }
4526 else
4527 {
4528 game->set_life(zc_max(game->get_life()-1,0));
4529 }
4530 }
4531 }
4532
4533 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4534
4535 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4536
4537 verifyBothWeapons();
4538
4539 bottom:
4540
4541
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(input_idle(true) > after_time())
4542 {
4543 Matrix(ss_speed, ss_density, 0);
4544 game_pal();
4545 }
4546 9284954 }
4547
4548 708134 void checkQuitKeys()
4549 {
4550 #ifndef ALLEGRO_MACOSX
4551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708134 times.
708134 if(key[KEY_F9]) f_Quit(qRESET);
4552
4553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708134 times.
708134 if(key[KEY_F10]) f_Quit(qEXIT);
4554 #else
4555 if(key[KEY_F7]) f_Quit(qRESET);
4556
4557 if(key[KEY_F8]) f_Quit(qEXIT);
4558 #endif
4559 708134 }
4560
4561 9284954 bool CheatModifierKeys()
4562 {
4563 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4564 // to trigger cheats.
4565
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if (replay_is_replaying())
4566 9284954 return false;
4567
4568 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4569 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4570 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4571 {
4572 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4573 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4574 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4575 {
4576 return true;
4577 }
4578 }
4579 return false;
4580 9284954 }
4581
4582 //99:05:54, for some reason?
4583 #define OLDMAXTIME 21405240
4584 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4585 #define MAXTIME 1944000000
4586
4587 9285079 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4588 {
4589
2/2
✓ Branch 0 taken 9164956 times.
✓ Branch 1 taken 120123 times.
9285079 if(zcmusic!=NULL)
4590 {
4591 120123 zcmusic_poll();
4592 120123 }
4593 9285079 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4594
4595 9285079 updatescr(allowwavy);
4596
4597 9285079 Advance=false;
4598
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9285079 times.
9285079 while(Paused && !Advance && !Quit)
4599 {
4600 // have to call this, otherwise we'll get an infinite loop
4601 syskeys();
4602 if(allowF6Script)
4603 {
4604 FFCore.runF6Engine();
4605 }
4606 throttleFPS();
4607
4608 #ifdef _WIN32
4609
4610 if(use_dwm_flush)
4611 {
4612 do_DwmFlush();
4613 }
4614
4615 #endif
4616
4617 // to keep music playing
4618 if(zcmusic!=NULL)
4619 {
4620 zcmusic_poll();
4621 }
4622
4623 update_hw_screen();
4624 }
4625
4626
2/2
✓ Branch 0 taken 9284967 times.
✓ Branch 1 taken 112 times.
9285079 if(Quit)
4627 112 return;
4628
4629
3/4
✓ Branch 0 taken 8984007 times.
✓ Branch 1 taken 300960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8984007 times.
9284967 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4630 8984007 game->change_time(1);
4631
4632 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4633
4634 9284967 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4635
2/2
✓ Branch 0 taken 18170 times.
✓ Branch 1 taken 9266797 times.
9284967 if (replay_version_check(0, 16))
4636 9266797 should_reset_down_state = replay_version_check(11, 16);
4637
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2335287 times.
9284967 if (should_reset_down_state)
4638 {
4639
2/2
✓ Branch 0 taken 42035166 times.
✓ Branch 1 taken 2335287 times.
44370453 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4640 42035166 down_control_states[i] = raw_control_state[i];
4641 2335287 }
4642
4643
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_active())
4644 {
4645
2/2
✓ Branch 0 taken 1270450 times.
✓ Branch 1 taken 8014504 times.
9284954 if (replay_version_check(3))
4646 8014504 replay_poll();
4647
4648
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2338856 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9284954 if (replay_version_check(11) || replay_version_check(6, 8))
4649 2439391 replay_peek_input();
4650 9284954 }
4651
4652 9284967 load_control_called_this_frame = false;
4653
4654 9284967 poll_keyboard();
4655 9284967 update_keys();
4656
4657 9284967 ++frame;
4658
4659
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_replaying())
4660 9284954 replay_do_cheats();
4661 9284967 syskeys();
4662
4663 // The mouse variables can change from the mouse thread at anytime during a frame,
4664 // so save the result at the start so that replaying is consistent.
4665 9284967 script_mouse_x = gui_mouse_x();
4666 9284967 script_mouse_y = gui_mouse_y();
4667 9284967 script_mouse_z = mouse_z;
4668 9284967 script_mouse_b = mouse_b;
4669
4670 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4671 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4672 // approach here means it doesn't matter which call adds the cheat.
4673 9284967 cheats_execute_queued();
4674
4675
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_replaying())
4676 9284954 replay_peek_quit();
4677
2/2
✓ Branch 0 taken 9284954 times.
✓ Branch 1 taken 13 times.
9284967 if (GameFlags & GAMEFLAG_TRYQUIT)
4678 13 replay_step_quit(0);
4679
2/2
✓ Branch 0 taken 2933 times.
✓ Branch 1 taken 9282034 times.
9284967 if(allowF6Script)
4680 9282034 FFCore.runF6Engine();
4681
2/2
✓ Branch 0 taken 9284667 times.
✓ Branch 1 taken 300 times.
9284967 if (Quit)
4682 300 replay_step_quit(Quit);
4683 // Someday... maybe install a Turbo button here?
4684 9284967 throttleFPS();
4685
4686 #ifdef _WIN32
4687
4688 if(use_dwm_flush)
4689 {
4690 do_DwmFlush();
4691 }
4692
4693 #endif
4694
4695 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4696
2/2
✓ Branch 0 taken 68757 times.
✓ Branch 1 taken 9216210 times.
9284967 if(sfxcleanup)
4697 9216210 sfx_cleanup();
4698
4699 9284967 jit_poll();
4700 9285079 }
4701
4702 101 void zapout()
4703 {
4704 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4705 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4706
4707 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4708 101 script_drawing_commands.Clear();
4709
4710 // zap out
4711
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4712 {
4713 2424 draw_fuzzy(i);
4714 2424 advanceframe(true);
4715
4716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4717 {
4718 break;
4719 }
4720 2424 }
4721 101 }
4722
4723 101 void zapin()
4724 {
4725 101 FFCore.warpScriptCheck();
4726 101 draw_screen(tmpscr);
4727 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4728 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4729 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4730
4731 // zap out
4732 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4733
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4734 {
4735 2424 draw_fuzzy(i);
4736 2424 advanceframe(true);
4737
4738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4739 {
4740 break;
4741 }
4742 2424 }
4743 101 }
4744
4745
4746 65 void wavyout(bool showhero)
4747 {
4748 65 draw_screen(tmpscr, showhero);
4749 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4750
4751 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4752 65 clear_to_color(wavebuf,0);
4753 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4754
4755 static PALETTE wavepal;
4756
4757 int32_t ofs;
4758 65 int32_t amplitude=8;
4759
4760 65 int32_t wavelength=4;
4761 65 double palpos=0, palstep=4, palstop=126;
4762
4763 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4764
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4765 {
4766
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4767 {
4768 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4769 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4770 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4771 698880 }
4772
4773 2730 palpos+=palstep;
4774
4775
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4776 {
4777 2730 hw_palette = &wavepal;
4778 2730 update_hw_pal = true;
4779 2730 }
4780 else
4781 {
4782 hw_palette = &RAMpal;
4783 update_hw_pal = true;
4784 }
4785
4786
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4787 {
4788
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4789 {
4790 117411840 ofs=0;
4791
4792
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4793 {
4794 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4795 28654080 }
4796
4797 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4798 117411840 }
4799 458640 }
4800
4801 2730 advanceframe(true);
4802
4803 // animate_combos();
4804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4805 break;
4806 2730 }
4807
4808 65 destroy_bitmap(wavebuf);
4809 65 }
4810
4811 65 void wavyin()
4812 {
4813 65 draw_screen(tmpscr);
4814 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4815
4816 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4817 65 clear_to_color(wavebuf,0);
4818 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4819
4820 static PALETTE wavepal;
4821
4822 //Breaks dark rooms.
4823 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4824 /*
4825 loadfullpal();
4826 loadlvlpal(DMaps[currdmap].color);
4827 ringcolor(false);
4828 */
4829 65 refreshpal=false;
4830 int32_t ofs;
4831 65 int32_t amplitude=8;
4832 65 int32_t wavelength=4;
4833 65 double palpos=168, palstep=4, palstop=126;
4834
4835 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4836
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4837 {
4838
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4839 {
4840 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4841 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4842 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4843 698880 }
4844
4845 2730 palpos-=palstep;
4846
4847
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4848 {
4849 2730 hw_palette = &wavepal;
4850 2730 update_hw_pal = true;
4851 2730 }
4852 else
4853 {
4854 hw_palette = &RAMpal;
4855 update_hw_pal = true;
4856 }
4857
4858
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4859 {
4860
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4861 {
4862 117411840 ofs=0;
4863
4864
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4865 {
4866 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4867 29352960 }
4868
4869 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4870 117411840 }
4871 458640 }
4872
4873 2730 advanceframe(true);
4874 // animate_combos();
4875
4876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4877 break;
4878 2730 }
4879
4880 65 destroy_bitmap(wavebuf);
4881 65 }
4882
4883 2168 void blackscr(int32_t fcnt,bool showsubscr)
4884 {
4885 2168 reset_pal_cycling();
4886 2168 script_drawing_commands.Clear();
4887
4888 2168 FFCore.warpScriptCheck();
4889 2168 bool showtime = game->should_show_time();
4890
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4891 {
4892 64970 clear_bitmap(framebuf);
4893
4894
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4895 {
4896 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4897
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4898 {
4899 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4900 750 }
4901 39890 }
4902
4903 64970 advanceframe(true);
4904
4905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4906 break;
4907
4908 64970 --fcnt;
4909 }
4910 2168 }
4911
4912 1011 void openscreen(int32_t shape)
4913 {
4914 1011 reset_pal_cycling();
4915 1011 black_opening_count=0;
4916
4917
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1011 if(COOLSCROLL || shape>-1)
4918 {
4919 911 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4920 911 return;
4921 }
4922 else
4923 {
4924 100 Hero.setDontDraw(true);
4925 100 show_subscreen_dmap_dots=false;
4926 100 show_subscreen_numbers=false;
4927 // show_subscreen_items=false;
4928 100 show_subscreen_life=false;
4929 }
4930
4931 100 int32_t x=128;
4932
4933 100 FFCore.warpScriptCheck();
4934
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4935 {
4936 8000 draw_screen(tmpscr);
4937 //? draw_screen already draws the subscreen -DD
4938 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4939 8000 x=128-(((i*128/80)/8)*8);
4940
4941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4942 {
4943 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4944 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4945 8000 }
4946
4947 8000 advanceframe(true);
4948
4949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
4950 {
4951 break;
4952 }
4953 8000 }
4954
4955 100 Hero.setDontDraw(false);
4956 100 show_subscreen_items=true;
4957 100 show_subscreen_dmap_dots=true;
4958 1011 }
4959
4960 void closescreen(int32_t shape)
4961 {
4962 reset_pal_cycling();
4963 black_opening_count=0;
4964
4965 if(COOLSCROLL || shape>-1)
4966 {
4967 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4968 return;
4969 }
4970 else
4971 {
4972 Hero.setDontDraw(true);
4973 show_subscreen_dmap_dots=false;
4974 show_subscreen_numbers=false;
4975 // show_subscreen_items=false;
4976 show_subscreen_life=false;
4977 }
4978
4979 int32_t x=128;
4980
4981 FFCore.warpScriptCheck();
4982 for(int32_t i=79; i>=0; --i)
4983 {
4984 draw_screen(tmpscr);
4985 //? draw_screen already draws the subscreen -DD
4986 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4987 x=128-(((i*128/80)/8)*8);
4988
4989 if(x>0)
4990 {
4991 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4992 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4993 }
4994
4995 advanceframe(true);
4996
4997 if(Quit)
4998 {
4999 break;
5000 }
5001 }
5002
5003 Hero.setDontDraw(false);
5004 show_subscreen_items=true;
5005 show_subscreen_dmap_dots=true;
5006 }
5007
5008 179 int32_t TriforceCount()
5009 {
5010 179 int32_t c=0;
5011
5012
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5013
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5014 1044 ++c;
5015
5016 179 return c;
5017 }
5018
5019 int32_t onCustomGame()
5020 {
5021 int32_t file = getsaveslot();
5022
5023 if(file < 0)
5024 return D_O_K;
5025
5026 bool ret = (custom_game(file)!=0);
5027 return ret ? D_CLOSE : D_O_K;
5028 }
5029
5030 int32_t onContinue()
5031 {
5032 return D_CLOSE;
5033 }
5034
5035 int32_t onEsc() // Unused?? -L
5036 {
5037 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5038 }
5039
5040 int32_t onVsync()
5041 {
5042 Throttlefps = !Throttlefps;
5043 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5044 return D_O_K;
5045 }
5046
5047 int32_t onWinPosSave()
5048 {
5049 SaveWinPos = !SaveWinPos;
5050 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5051 return D_O_K;
5052 }
5053 int32_t onIntegerScaling()
5054 {
5055 scaleForceInteger = !scaleForceInteger;
5056 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5057 return D_O_K;
5058 }
5059 int32_t onStretchGame()
5060 {
5061 stretchGame = !stretchGame;
5062 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5063 return D_O_K;
5064 }
5065
5066 int32_t onClickToFreeze()
5067 {
5068 ClickToFreeze = !ClickToFreeze;
5069 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5070 return D_O_K;
5071 }
5072
5073 int32_t OnSaveZCConfig()
5074 {
5075 if(jwin_alert3(
5076 "Save Configuration",
5077 "Are you sure that you wish to save your present configuration settings?",
5078 "This will overwrite your prior settings!",
5079 NULL,
5080 "&Yes",
5081 "&No",
5082 NULL,
5083 'y',
5084 'n',
5085 0,
5086 get_zc_font(font_lfont)) == 1)
5087 {
5088 save_game_configs();
5089 return D_O_K;
5090 }
5091 else return D_O_K;
5092 }
5093
5094 int32_t OnnClearQuestDir()
5095 {
5096 if(jwin_alert3(
5097 "Clear Current Directory Cache",
5098 "Are you sure that you wish to clear the current cached directory?",
5099 "This will default the current directory to the ROOT for this instance of ZC Player!",
5100 NULL,
5101 "&Yes",
5102 "&No",
5103 NULL,
5104 'y',
5105 'n',
5106 0,
5107 get_zc_font(font_lfont)) == 1)
5108 {
5109 zc_set_config("zeldadx","win_qst_dir","");
5110 flush_config_file();
5111 strcpy(qstdir,"");
5112 #ifdef __EMSCRIPTEN__
5113 em_sync_fs();
5114 #endif
5115 return D_O_K;
5116 }
5117 else return D_O_K;
5118 }
5119
5120
5121 int32_t onConsoleZASM()
5122 {
5123 if ( !zasm_debugger )
5124 {
5125 AlertDialog("WARNING: ZASM Debugger",
5126 "Enabling this will open the ZASM Debugger Console"
5127 "\nThis will likely grind ZC to a halt with lag."
5128 "\nTo make any use of this, it is suggested that you read"
5129 "\nthe documentation for 'void Breakpoint(char[] string);'"
5130 " in 'ZScript_Additions.txt'"
5131 "\nThis is not recommended for normal users,"
5132 " and is only intended for ZC developers,"
5133 "\nor quest developers coding directly in ZASM"
5134 "\nAre you sure that you wish to open the ZASM Debugger?",
5135 [&](bool ret,bool)
5136 {
5137 if(ret)
5138 {
5139 FFCore.ZASMPrint(true);
5140 }
5141 }).show();
5142 return D_O_K;
5143 }
5144 else
5145 {
5146 FFCore.ZASMPrint(false);
5147 return D_O_K;
5148 }
5149 }
5150
5151
5152 int32_t onConsoleZScript()
5153 {
5154 if ( !zscript_debugger )
5155 {
5156 AlertDialog("ZScript Debugger",
5157 "Enabling this will open the ZScript Debugger Console"
5158 "\nThis will display any messages logged by scripts,"
5159 " including script errors."
5160 "\nAre you sure that you wish to open the ZScript Debugger?",
5161 [&](bool ret,bool)
5162 {
5163 if(ret)
5164 {
5165 FFCore.ZScriptConsole(true);
5166 }
5167 }).show();
5168 return D_O_K;
5169 }
5170 else
5171 {
5172 FFCore.ZScriptConsole(false);
5173 return D_O_K;
5174 }
5175 }
5176
5177 int32_t onClrConsoleOnReload()
5178 {
5179 clearConsoleOnReload = !clearConsoleOnReload;
5180 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5181 return D_O_K;
5182 }
5183 int32_t onClrConsoleOnLoad()
5184 {
5185 clearConsoleOnLoad = !clearConsoleOnLoad;
5186 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5187 return D_O_K;
5188 }
5189
5190
5191 int32_t onFrameSkip()
5192 {
5193 FrameSkip = !FrameSkip;
5194 return D_O_K;
5195 }
5196
5197 int32_t onSaveDragResize()
5198 {
5199 SaveDragResize = !SaveDragResize;
5200 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5201 return D_O_K;
5202 }
5203
5204 int32_t onDragAspect()
5205 {
5206 DragAspect = !DragAspect;
5207 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5208 return D_O_K;
5209 }
5210
5211 int32_t onTransLayers()
5212 {
5213 TransLayers = !TransLayers;
5214 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5215 return D_O_K;
5216 }
5217
5218 int32_t onNESquit()
5219 {
5220 NESquit = !NESquit;
5221 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5222 return D_O_K;
5223 }
5224
5225 int32_t onVolKeys()
5226 {
5227 volkeys = !volkeys;
5228 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5229 return D_O_K;
5230 }
5231
5232 int32_t onShowFPS()
5233 {
5234 ShowFPS = !ShowFPS;
5235 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5236 return D_O_K;
5237 }
5238
5239 1095624572 bool is_Fkey(int32_t k)
5240 {
5241
2/2
✓ Branch 0 taken 111419448 times.
✓ Branch 1 taken 984205124 times.
1095624572 switch(k)
5242 {
5243 case KEY_F1:
5244 case KEY_F2:
5245 case KEY_F3:
5246 case KEY_F4:
5247 case KEY_F5:
5248 case KEY_F6:
5249 case KEY_F7:
5250 case KEY_F8:
5251 case KEY_F9:
5252 case KEY_F10:
5253 case KEY_F11:
5254 case KEY_F12:
5255 111419448 return true;
5256 }
5257
5258 984205124 return false;
5259 1095624572 }
5260
5261 void kb_getkey(DIALOG *d);
5262
5263 //Used by all keyboard key settings dialogues.
5264 void kb_clearjoystick(DIALOG *d)
5265 {
5266 d->flags|=D_SELECTED;
5267
5268 jwin_button_proc(MSG_DRAW,d,0);
5269 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5270 // text_mode(vc(11));
5271 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5272 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5273
5274 update_hw_screen(true);
5275
5276 clear_keybuf();
5277 int32_t k = next_press_key();
5278 clear_keybuf();
5279
5280 //shnarf
5281 //47=f1
5282 //59=esc
5283 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5284 // *((int32_t*)d->dp3) = k;
5285 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5286
5287
5288 d->flags&=~D_SELECTED;
5289 }
5290
5291 //Clears key to 0.
5292 //Used by all keyboard key settings dialogues.
5293 void kb_clearkey(DIALOG *d);
5294
5295 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5296 {
5297 switch(msg)
5298 {
5299 case MSG_KEY:
5300 case MSG_CLICK:
5301
5302 kb_clearjoystick(d);
5303
5304 while(gui_mouse_b())
5305 {
5306 clear_keybuf();
5307 rest(1);
5308 }
5309
5310 return D_REDRAW;
5311 }
5312
5313 return jwin_button_proc(msg,d,c);
5314 }
5315
5316 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5317 //Only used in keyboard settings dialogues to clear keys.
5318 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5319
5320 void j_getbtn(DIALOG *d)
5321 {
5322 d->flags|=D_SELECTED;
5323 jwin_button_proc(MSG_DRAW,d,0);
5324 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5325 // text_mode(vc(11));
5326 int32_t y = screen->h/2 - 12;
5327 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5328 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5329 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5330
5331 update_hw_screen(true);
5332
5333 int32_t b = next_press_btn();
5334
5335 if(b>=0)
5336 *((int32_t*)d->dp3) = b;
5337
5338 d->flags&=~D_SELECTED;
5339
5340 if (player)
5341 player->joy_on = TRUE;
5342 }
5343
5344 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5345 {
5346 switch(msg)
5347 {
5348 case MSG_KEY:
5349 case MSG_CLICK:
5350
5351 j_getbtn(d);
5352
5353 while(gui_mouse_b()) {
5354 rest(1);
5355 clear_keybuf();
5356 }
5357
5358 return D_REDRAW;
5359 }
5360
5361 return jwin_button_proc(msg,d,c);
5362 }
5363
5364 //shnarf
5365 extern const char *key_str[];
5366 std::string get_keystr(int key);
5367
5368 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5369 //extern int32_t zcmusic_bufsz;
5370
5371 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5372 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5373
5374 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5375 {
5376 //these are here to bypass compiler warnings about unused arguments
5377 c=c;
5378
5379 if(msg==MSG_DRAW)
5380 {
5381 switch(d->w)
5382 {
5383 case 0:
5384 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5385 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5386 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5387 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5388 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5389 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5390 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5391 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5392 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5393 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5394 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5395 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5396 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5397 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5398 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5399 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5400 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5401 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5402 break;
5403
5404 case 1:
5405 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5406 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5407 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5408 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5409 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5410 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5411 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5412 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5413 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5414 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5415 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5416 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5417 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5418 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5419 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5420 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5421 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5422 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5423 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5424 break;
5425
5426 case 2:
5427 sprintf(str_a," %3d",midi_volume);
5428 sprintf(str_b," %3d",digi_volume);
5429 sprintf(str_l," %3d",emusic_volume);
5430 sprintf(str_m," %3dKB",zcmusic_bufsz);
5431 sprintf(str_r," %3d",sfx_volume);
5432 strcpy(str_s,pan_str[pan_style]);
5433 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5434 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5435 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5436 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5437 break;
5438 }
5439 }
5440
5441 return D_O_K;
5442 }
5443
5444 int32_t set_vol(void *dp3, int32_t d2)
5445 {
5446 switch(((int32_t*)dp3)[0])
5447 {
5448 case 0:
5449 midi_volume = zc_min(d2<<3,255);
5450 break;
5451
5452 case 1:
5453 digi_volume = zc_min(d2<<3,255);
5454 break;
5455
5456 case 2:
5457 emusic_volume = zc_min(d2<<3,255);
5458 break;
5459
5460 case 3:
5461 sfx_volume = zc_min(d2<<3,255);
5462 break;
5463 }
5464
5465 // text_mode(vc(11));
5466 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5467 return D_O_K;
5468 }
5469
5470 int32_t set_pan(void *dp3, int32_t d2)
5471 {
5472 pan_style = vbound(d2,0,3);
5473 // text_mode(vc(11));
5474 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5475 return D_O_K;
5476 }
5477
5478 int32_t set_buf(void *dp3, int32_t d2)
5479 {
5480 // text_mode(vc(11));
5481 zcmusic_bufsz = d2 + 1;
5482 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5483 return D_O_K;
5484 }
5485
5486 static int32_t gamepad_btn_list[] =
5487 {
5488 6,
5489 7,8,9,10,11,12,13,14,15,16,17,
5490 18,19,20,21,22,23,24,25,26,27,28,
5491 29,30,31,32,33,34,35,36,37,38,39,
5492 -1
5493 };
5494
5495 static int32_t gamepad_dirs_list[] =
5496 {
5497 40,41,42,43,
5498 44,45,46,47,
5499 48,49,50,51,
5500 52,53,54,55,
5501 56,
5502 -1
5503 };
5504
5505 static TABPANEL gamepad_tabs[] =
5506 {
5507 // (text)
5508 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5509 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5510 { NULL, 0, NULL, 0, NULL }
5511 };
5512
5513 static DIALOG gamepad_dlg[] =
5514 {
5515 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5516 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5517 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5518 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5519 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5520 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5521 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5522 // 6
5523 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5524 // 7
5525 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5526 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5527 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5528 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5529 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5530 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5531 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5532 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5533 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5534 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5535 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5536 // 18
5537 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5538 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5539 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5540 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5541 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5542 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5543 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5544 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5545 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5546 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5547 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5548 // 29
5549 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5550 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5551 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5552 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5553 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5554 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5555 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5556 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5557 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5558 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5559 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5560 // 40
5561 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5562 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5563 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5564 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5565 // 44
5566 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5567 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5568 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5569 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5570 // 48
5571 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5572 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5573 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5574 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5575 // 52
5576 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5577 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5578 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5579 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5580 // 56
5581 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5582 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5583 };
5584
5585 static int32_t keyboard_keys_list[] =
5586 {
5587 6,7,8,9,10,
5588 11,12,13,14,15,16,17,18,19,20,
5589 21,22,23,24,25,26,27,28,29,30,
5590 31,32,33,34,35,36,37,38,39,40,
5591 -1
5592 };
5593
5594 static int32_t keyboard_dirs_list[] =
5595 {
5596 41,42,43,44,
5597 45,46,47,48,
5598 49,50,51,52,
5599 53,54,55,56,
5600 -1
5601 };
5602
5603 static int32_t keyboard_mods_list[] =
5604 {
5605 57,58,59,60,
5606 61,62,63,64,
5607 65,66,67,68,
5608 69,70,71,72,
5609 -1
5610 };
5611
5612 static TABPANEL keyboard_control_tabs[] =
5613 {
5614 // (text)
5615 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5616 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5617 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5618 { NULL, 0, NULL, 0, NULL }
5619 };
5620
5621 static DIALOG keyboard_control_dlg[] =
5622 {
5623 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5624 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5625 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5626 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5627 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5628 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5629 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5630 // Keys
5631 // 6
5632 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5633 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5634 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5635 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5636 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5637 // 11
5638 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5639 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5640 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5641 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5642 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5643 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5644 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5645 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5646 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5647 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5648 // 21
5649 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5650 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5651 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5652 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5653 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5654 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5655 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5656 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5657 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5658 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5659 // 31
5660 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5661 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5662 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5663 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5664 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5665 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5666 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5667 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5668 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5669 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5670 // Dirs
5671 // 41
5672 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5673 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5674 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5675 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5676 // 45
5677 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5678 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5679 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5680 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5681 // 49
5682 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5683 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5684 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5685 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5686 // 53
5687 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5688 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5689 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5690 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5691 // Mods
5692 // 57
5693 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5694 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5695 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5696 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5697 // 61
5698 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5699 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5700 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5701 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5702 // 65
5703 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5704 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5705 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5706 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5707 // 69
5708 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5709 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5710 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5711 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5712 // 73
5713 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5714 };
5715
5716 /*
5717 int32_t midi_dp[3] = {0,147,104};
5718 int32_t digi_dp[3] = {1,147,120};
5719 int32_t pan_dp[3] = {0,147,136};
5720 int32_t buf_dp[3] = {0,147,152};
5721 */
5722 int32_t midi_dp[3] = {0,0,0};
5723 int32_t digi_dp[3] = {1,0,0};
5724 int32_t emus_dp[3] = {2,0,0};
5725 int32_t buf_dp[3] = {0,0,0};
5726 int32_t sfx_dp[3] = {3,0,0};
5727 int32_t pan_dp[3] = {0,0,0};
5728
5729 static DIALOG sound_dlg[] =
5730 {
5731 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5732 116 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5733 116 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5734 116 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5735 116 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5736 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5737 116 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5738 116 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5739 116 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5740 116 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5741 116 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5742 // 10
5743 116 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5744 116 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5745 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5746 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5747 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5748 116 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5749 116 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5750 116 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5751 116 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5752 116 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5753 //20
5754 116 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5755 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5756 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5757 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5758 116 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5759 116 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5760 116 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5761 116 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5762 116 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5763 116 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5764 //30
5765 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5766 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5767 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5768 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5769 };
5770
5771 char zc_builddate[80];
5772 char zc_aboutstr[80];
5773
5774 static DIALOG about_dlg[] =
5775 {
5776 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5777 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5778 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5779 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5780 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5781 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5782 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5783 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5784 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5785 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5786 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5788 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5789 };
5790
5791
5792 static DIALOG quest_dlg[] =
5793 {
5794 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5795 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5796 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5797 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5798 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5799 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5800 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5801 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5802 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5803 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5804 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5805 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5806 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5807 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5808 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5809 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5810 };
5811
5812 static DIALOG triforce_dlg[] =
5813 {
5814 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5815 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5816 // 1
5817 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5818 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5819 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5820 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5821 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5822 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5823 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5824 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5825 // 9
5826 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5827 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5828 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5829 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5830 };
5831
5832 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5833 {
5834 go();
5835 int32_t ret=0;
5836 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5837 comeback();
5838 return ret != 0;
5839 }
5840
5841
5842 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5843 {
5844 if(def!=modulepath)
5845 strcpy(modulepath,def);
5846
5847 if(!usefilename)
5848 {
5849 int32_t i=(int32_t)strlen(modulepath);
5850
5851 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5852 modulepath[i--]=0;
5853 }
5854
5855 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5856 int32_t ret=0;
5857 int32_t sel=0;
5858
5859 if(list==NULL)
5860 {
5861 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5862 }
5863 else
5864 {
5865 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5866 }
5867
5868 return ret!=0;
5869 }
5870
5871 //The Dialogue that loads a ZMOD Module File
5872 int32_t zc_load_zmod_module_file()
5873 {
5874 if ( Playing )
5875 {
5876 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5877 return -1;
5878 }
5879 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5880 return D_CLOSE;
5881
5882 FILE *tempmodule = fopen(modulepath,"r");
5883
5884 if(tempmodule == NULL)
5885 {
5886 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5887 return -1;
5888 }
5889
5890
5891 //Set the module path:
5892 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5893 strcpy(moduledata.module_name, modulepath);
5894 al_trace("New Module Path is: %s \n", moduledata.module_name);
5895 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5896 zcm.init(true); //Load the module values.
5897 moduledata.refresh_title_screen = 1;
5898 // refresh_select_screen = 1;
5899 build_biic_list();
5900 return D_O_K;
5901 }
5902
5903 static DIALOG module_info_dlg[] =
5904 {
5905 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5906
5907
5908 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5909 //1
5910 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5911 //2
5912 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5913 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5914 //4
5915 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5916 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5917 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5918 //7
5919
5920 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5921 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5922 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5923 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5924 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5925 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5926 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5927 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5928 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5929
5930 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5931 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5932 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5933 };
5934
5935 void about_zcplayer_module(const char *prompt,int32_t initialval)
5936 {
5937
5938 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5939 if ( moduledata.moduletitle[0] != 0 )
5940 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5941
5942 if ( moduledata.moduleauthor[0] != 0 )
5943 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5944
5945 if ( moduledata.moduleinfo0[0] != 0 )
5946 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5947 if ( moduledata.moduleinfo1[0] != 0 )
5948 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5949 if ( moduledata.moduleinfo2[0] != 0 )
5950 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5951 if ( moduledata.moduleinfo3[0] != 0 )
5952 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5953 if ( moduledata.moduleinfo4[0] != 0 )
5954 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5955
5956 char module_date[255];
5957 memset(module_date, 0, sizeof(module_date));
5958 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5959 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5960
5961
5962
5963 char module_vers[255];
5964 memset(module_vers, 0, sizeof(module_vers));
5965 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5966
5967
5968 //sprintf(tilecount,"%d",1);
5969
5970 char module_build[255];
5971 memset(module_build, 0, sizeof(module_build));
5972 if ( moduledata.modbeta )
5973 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5974 else
5975 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5976
5977 module_info_dlg[12].dp = (char*)module_date;
5978 module_info_dlg[13].dp = (char*)module_vers;
5979 module_info_dlg[14].dp = (char*)module_build;
5980
5981 large_dialog(module_info_dlg);
5982
5983 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5984 jwin_center_dialog(module_info_dlg);
5985
5986
5987 }
5988
5989 int32_t onAbout_ZCP_Module()
5990 {
5991 about_zcplayer_module("About Module (.zmod)", 0);
5992 return D_O_K;
5993 }
5994
5995 //New Modules Menu for 2.55+
5996 static MENU zcmodule_menu[] =
5997 {
5998 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
5999 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6000
6001 { NULL, NULL, NULL, 0, NULL }
6002 };
6003
6004 int32_t onToggleRecordingNewSaves()
6005 {
6006 if (zc_get_config("zeldadx", "replay_new_saves", false))
6007 {
6008 zc_set_config("zeldadx", "replay_new_saves", false);
6009 }
6010 else
6011 {
6012 zc_set_config("zeldadx", "replay_new_saves", true);
6013 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6014 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6015 }
6016 return D_O_K;
6017 }
6018
6019 int32_t onToggleSnapshotAllFrames()
6020 {
6021 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6022 return D_O_K;
6023 }
6024
6025 int32_t onStopReplayOrRecord()
6026 {
6027 if (replay_is_replaying())
6028 {
6029 replay_quit();
6030 }
6031 else if (replay_get_mode() == ReplayMode::Record)
6032 {
6033 if (!replay_get_meta_bool("test_mode"))
6034 {
6035 jwin_alert("Recording", "You cannot stop recording a save file.",
6036 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6037 return D_CLOSE;
6038 }
6039
6040 if (jwin_alert("Stop Recording",
6041 "Save replay to disk and stop recording?",
6042 "This will stop the recording.",
6043 NULL,
6044 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6045 return D_CLOSE;
6046
6047 replay_save();
6048 replay_stop();
6049 }
6050 return D_O_K;
6051 }
6052
6053 static int32_t handle_on_load_replay(ReplayMode mode)
6054 {
6055 if (Playing)
6056 {
6057 if (jwin_alert("Replay - Warning!",
6058 "Loading a replay will exit the current game.",
6059 "All unsaved progress will be lost.",
6060 "Do you wish to continue?",
6061 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6062 return D_CLOSE;
6063 }
6064
6065 std::string mode_string = replay_mode_to_string(mode);
6066 mode_string[0] = std::toupper(mode_string[0]);
6067
6068 std::string line_1 = "Select a replay file to play back.";
6069 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6070 std::string line_3 = "You can stop the replay and take over manually any time.";
6071 if (mode == ReplayMode::Update)
6072 {
6073 line_1 = "Select a replay file to update.";
6074 line_2 = "WARNING: be sure to back up the zplay file";
6075 line_3 = "and verify that the updated replay works as expected!";
6076 }
6077
6078 if (jwin_alert(mode_string.c_str(),
6079 line_1.c_str(),
6080 line_2.c_str(),
6081 line_3.c_str(),
6082 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6083 {
6084 char replay_path[2048];
6085 strcpy(replay_path, "replays/");
6086 if (jwin_file_select_ex(
6087 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6088 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6089 return D_CLOSE;
6090
6091 replay_quit();
6092 load_replay_file_deferred(mode, replay_path);
6093 Quit = qRESET;
6094 return D_CLOSE;
6095 }
6096 return D_O_K;
6097 }
6098
6099 int32_t onLoadReplay()
6100 {
6101 return handle_on_load_replay(ReplayMode::Replay);
6102 }
6103
6104 int32_t onLoadReplayAssert()
6105 {
6106 return handle_on_load_replay(ReplayMode::Assert);
6107 }
6108
6109 int32_t onLoadReplayUpdate()
6110 {
6111 return handle_on_load_replay(ReplayMode::Update);
6112 }
6113
6114 int32_t onSaveReplay()
6115 {
6116 if (replay_get_mode() == ReplayMode::Record)
6117 {
6118 if (!replay_get_meta_bool("test_mode"))
6119 {
6120 if (jwin_alert("Save Replay",
6121 "This will save a copy of the replay up to this point.",
6122 "The official replay file will be untouched.",
6123 "Do you wish to continue?",
6124 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6125 return D_CLOSE;
6126
6127 char replay_path[2048];
6128 strcpy(replay_path, replay_get_replay_path().string().c_str());
6129 if (jwin_file_select_ex(
6130 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6131 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6132 return D_CLOSE;
6133
6134 if (fileexists(replay_path))
6135 {
6136 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6137 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6138 return D_CLOSE;
6139 }
6140
6141 replay_save(replay_path);
6142 }
6143 else
6144 {
6145 replay_save();
6146 }
6147 }
6148 return D_O_K;
6149 }
6150
6151 static MENU replay_menu[] =
6152 {
6153 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6154 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6155 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6156 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6157 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6158 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6159 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6160
6161 { NULL, NULL, NULL, 0, NULL }
6162 };
6163
6164 static DIALOG credits_dlg[] =
6165 {
6166 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6167 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6168 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6169 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6170 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6171 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6172 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6173 };
6174
6175 116 static ListData dmap_list(dmaplist, &font);
6176
6177 static DIALOG goto_dlg[] =
6178 {
6179 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6180 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6181 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6182 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6183 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6184 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6185 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6186 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6187 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6188 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6189 };
6190
6191 int32_t onGoTo()
6192 {
6193 bool music = false;
6194 music = music;
6195 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6196
6197 goto_dlg[0].dp2=get_zc_font(font_lfont);
6198 goto_dlg[4].d2=cheat_goto_dmap;
6199 goto_dlg[6].dp=cheat_goto_screen_str;
6200
6201 clear_keybuf();
6202
6203 large_dialog(goto_dlg);
6204
6205 if(zc_popup_dialog(goto_dlg,4)==1)
6206 {
6207 // dmap, screen
6208 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6209 };
6210
6211 return D_O_K;
6212 }
6213
6214 int32_t onGoToComplete()
6215 {
6216 if(!Playing)
6217 {
6218 return D_O_K;
6219 }
6220
6221 enter_sys_pal();
6222 music_pause();
6223 pause_all_sfx();
6224 onGoTo();
6225 eat_buttons();
6226
6227 zc_readrawkey(KEY_ESC);
6228
6229 exit_sys_pal();
6230 music_resume();
6231 resume_all_sfx();
6232 return D_O_K;
6233 }
6234
6235 int32_t onCredits()
6236 {
6237 go();
6238
6239 BITMAP *win = create_bitmap_ex(8,222,110);
6240
6241 if(!win)
6242 return D_O_K;
6243
6244 int32_t c=0;
6245 int32_t l=0;
6246 int32_t ol=-1;
6247 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6248 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6249 PALETTE tmppal;
6250
6251 rti_gui.transparency_index = 1;
6252
6253 clear_to_color(win, rti_gui.transparency_index);
6254 draw_rle_sprite(win,rle,0,0);
6255 credits_dlg[0].dp2=get_zc_font(font_lfont);
6256 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6257 credits_dlg[2].dp = win;
6258
6259 zc_set_palette_range(black_palette,0,127,false);
6260
6261 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6262
6263 BITMAP* old_screen = screen;
6264 BITMAP* gui_bmp = zc_get_gui_bmp();
6265 ASSERT(gui_bmp);
6266 clear_to_color(gui_bmp, rti_gui.transparency_index);
6267 screen = gui_bmp;
6268
6269 while(update_dialog(p))
6270 {
6271 throttleFPS();
6272 ++c;
6273 l = zc_max((c>>1)-30,0);
6274
6275 if(l > rle->h)
6276 l = c = 0;
6277
6278 if(l > rle->h - 112)
6279 l = rle->h - 112;
6280
6281 clear_bitmap(win);
6282 draw_rle_sprite(win,rle,0,0-l);
6283
6284 if(c<=64)
6285 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6286
6287 zc_set_palette_range(tmppal,0,127,false);
6288
6289 if(l!=ol)
6290 {
6291 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6292 SCRFIX();
6293 ol=l;
6294 }
6295
6296 update_hw_screen();
6297 }
6298
6299 screen = old_screen;
6300 system_pal(true);
6301 sys_mouse();
6302
6303 shutdown_dialog(p);
6304 destroy_bitmap(win);
6305 //comeback();
6306
6307 rti_gui.transparency_index = 0;
6308 clear_to_color(gui_bmp, rti_gui.transparency_index);
6309
6310 return D_O_K;
6311 }
6312
6313 const char *midilist(int32_t index, int32_t *list_size)
6314 {
6315 if(index<0)
6316 {
6317 *list_size=0;
6318
6319 for(int32_t i=0; i<MAXMIDIS; i++)
6320 if(tunes[i].data)
6321 ++(*list_size);
6322
6323 return NULL;
6324 }
6325
6326 int32_t i=0,m=0;
6327
6328 while(m<=index && i<=MAXMIDIS)
6329 {
6330 if(tunes[i].data)
6331 ++m;
6332
6333 ++i;
6334 }
6335
6336 --i;
6337
6338 if(i==MAXMIDIS && m<index)
6339 return "(null)";
6340
6341 return tunes[i].title;
6342 }
6343
6344 /* ------- MIDI info stuff -------- */
6345
6346 char *text;
6347 midi_info *zmi;
6348 bool dialog_running;
6349 bool listening;
6350
6351 void get_info(int32_t index);
6352
6353 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6354 {
6355 int32_t d2 = d->d2;
6356 int32_t ret = jwin_droplist_proc(msg,d,c);
6357
6358 if(d2!=d->d2)
6359 {
6360 get_info(d->d2);
6361 }
6362
6363 return ret;
6364 }
6365
6366 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6367 {
6368 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6369
6370 int32_t ret = jwin_button_proc(msg,d,c);
6371
6372 if(ret == D_CLOSE)
6373 {
6374 // get current midi index
6375 int32_t index = (d+(d->d1))->d2;
6376 int32_t i=0, m=0;
6377
6378 while(m<=index && i<=MAXMIDIS)
6379 {
6380 if(tunes[i].data)
6381 ++m;
6382
6383 ++i;
6384 }
6385
6386 --i;
6387 jukebox(i);
6388 listening = true;
6389 ret = D_O_K;
6390 }
6391
6392 return ret;
6393 }
6394
6395 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6396 {
6397 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6398
6399 int32_t ret = jwin_button_proc(msg,d,c);
6400
6401 if(ret == D_CLOSE)
6402 {
6403 // get current midi index
6404 int32_t index = (d+(d->d1))->d2;
6405 int32_t i=0, m=0;
6406
6407 while(m<=index && i<=MAXMIDIS)
6408 {
6409 if(tunes[i].data)
6410 ++m;
6411
6412 ++i;
6413 }
6414
6415 --i;
6416
6417 // get file name
6418
6419 int32_t sel=0;
6420 //struct ffblk f;
6421 char title[40] = "Save MIDI: ";
6422 char fname[2048];
6423 memset(fname,0,2048);
6424 static EXT_LIST list[] =
6425 {
6426 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6427 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6428 { NULL, NULL }
6429 };
6430
6431 strcpy(title+11, tunes[i].title);
6432 title[39] = '\0';
6433
6434 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6435 goto done;
6436
6437 if(exists(fname))
6438 {
6439 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6440 goto done;
6441 }
6442
6443 // save midi i
6444
6445 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6446 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6447
6448 done:
6449 chop_path(fname);
6450 ret = D_REDRAW;
6451 }
6452
6453 return ret;
6454 }
6455
6456 116 static ListData midi_list(midilist, &font);
6457
6458 static DIALOG midi_dlg[] =
6459 {
6460 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6461 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6462 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6463 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6464 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6465 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6466 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6467 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6468 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6469 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6470 };
6471
6472 void get_info(int32_t index)
6473 {
6474 int32_t i=0, m=0;
6475
6476 while(m<=index && i<=MAXMIDIS)
6477 {
6478 if(tunes[i].data)
6479 ++m;
6480
6481 ++i;
6482 }
6483
6484 --i;
6485
6486 if(i==MAXMIDIS && m<index)
6487 strcpy(text,"(null)");
6488 else
6489 {
6490 get_midi_info((MIDI*)tunes[i].data,zmi);
6491 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6492 }
6493
6494 midi_dlg[0].dp2=get_zc_font(font_lfont);
6495 midi_dlg[3].dp = text;
6496 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6497 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6498
6499 if(dialog_running)
6500 {
6501 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6502 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6503 }
6504 }
6505
6506 int32_t onMIDICredits()
6507 {
6508 text = (char*)malloc(4096);
6509 zmi = (midi_info*)malloc(sizeof(midi_info));
6510
6511 if(!text || !zmi)
6512 {
6513 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6514 return D_O_K;
6515 }
6516
6517 bool do_pause_midi = midi_pos >= 0 && currmidi;
6518 auto restore_midi = currmidi;
6519 if(do_pause_midi)
6520 {
6521 paused_midi_pos = midi_pos;
6522 stop_midi();
6523 midi_suspended = midissuspHALTED;
6524 }
6525
6526 midi_dlg[0].dp2=get_zc_font(font_lfont);
6527 midi_dlg[2].d1 = 0;
6528 midi_dlg[2].d2 = 0;
6529 midi_dlg[4].flags = D_EXIT;
6530 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6531
6532 listening = false;
6533 dialog_running=false;
6534 get_info(0);
6535
6536 dialog_running=true;
6537
6538 large_dialog(midi_dlg);
6539
6540 zc_popup_dialog(midi_dlg,0);
6541 dialog_running=false;
6542
6543 if(listening)
6544 music_stop();
6545
6546 if(do_pause_midi)
6547 {
6548 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6549 midi_suspended = midissuspRESUME;
6550 currmidi = restore_midi;
6551 midi_pos = paused_midi_pos;
6552 }
6553
6554 if(text) free(text);
6555 if(zmi) free(zmi);
6556 return D_O_K;
6557 }
6558
6559 int32_t onAbout()
6560 {
6561 char buf1[80]={0};
6562 std::ostringstream oss;
6563 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6564 oss << buf1 << '\n';
6565 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6566 oss << buf1 << '\n';
6567 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6568 oss << buf1 << '\n';
6569 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6570 oss << buf1 << '\n';
6571 sprintf(buf1, "Tag: %s", getReleaseTag());
6572 oss << buf1 << '\n';
6573
6574 InfoDialog("About ZC", oss.str()).show();
6575 return D_O_K;
6576 }
6577
6578 int32_t onQuest()
6579 {
6580 char fname[100];
6581 strcpy(fname, get_filename(qstpath));
6582 quest_dlg[0].dp2=get_zc_font(font_lfont);
6583 quest_dlg[1].dp = fname;
6584
6585 if(QHeader.quest_number==0)
6586 sprintf(str_a,"Custom");
6587 else
6588 sprintf(str_a,"%d",QHeader.quest_number);
6589
6590 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6591
6592 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6593 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6594
6595 large_dialog(quest_dlg);
6596
6597 zc_popup_dialog(quest_dlg, 0);
6598 return D_O_K;
6599 }
6600
6601 void call_vidmode_dlg();
6602 int32_t onVidMode()
6603 {
6604 call_vidmode_dlg();
6605 return D_O_K;
6606 }
6607
6608 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6609 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6610 //Added an extra statement, so that if the key is cleared to 0, the cleared
6611 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6612
6613 void load_ukeys(int32_t* arr)
6614 {
6615 arr[ukey_a] = Akey;
6616 arr[ukey_b] = Bkey;
6617 arr[ukey_s] = Skey;
6618 arr[ukey_l] = Lkey;
6619 arr[ukey_r] = Rkey;
6620 arr[ukey_p] = Pkey;
6621 arr[ukey_ex1] = Exkey1;
6622 arr[ukey_ex2] = Exkey2;
6623 arr[ukey_ex3] = Exkey3;
6624 arr[ukey_ex4] = Exkey4;
6625 arr[ukey_du] = DUkey;
6626 arr[ukey_dd] = DDkey;
6627 arr[ukey_dl] = DLkey;
6628 arr[ukey_dr] = DRkey;
6629 arr[ukey_mod1a] = cheat_modifier_keys[0];
6630 arr[ukey_mod1b] = cheat_modifier_keys[1];
6631 arr[ukey_mod2a] = cheat_modifier_keys[2];
6632 arr[ukey_mod2b] = cheat_modifier_keys[3];
6633 };
6634
6635 static const char* ukey_names[] = {
6636 "A", "B", "Start", "L", "R", "Map",
6637 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6638 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6639 "Cheat Mod R1", "Cheat Mod R2",
6640 };
6641 std::string get_ukey_name(int32_t k)
6642 {
6643 if (k < num_ukey) return ukey_names[k];
6644 return "";
6645 }
6646
6647 int32_t onKeyboard()
6648 {
6649 int32_t a = Akey;
6650 int32_t b = Bkey;
6651 int32_t s = Skey;
6652 int32_t l = Lkey;
6653 int32_t r = Rkey;
6654 int32_t p = Pkey;
6655 int32_t ex1 = Exkey1;
6656 int32_t ex2 = Exkey2;
6657 int32_t ex3 = Exkey3;
6658 int32_t ex4 = Exkey4;
6659 int32_t du = DUkey;
6660 int32_t dd = DDkey;
6661 int32_t dl = DLkey;
6662 int32_t dr = DRkey;
6663 int32_t mod1a = cheat_modifier_keys[0];
6664 int32_t mod1b = cheat_modifier_keys[1];
6665 int32_t mod2a = cheat_modifier_keys[2];
6666 int32_t mod2b = cheat_modifier_keys[3];
6667 bool done=false;
6668 int32_t ret;
6669
6670 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6671
6672 large_dialog(keyboard_control_dlg);
6673
6674 while(!done)
6675 {
6676 ret = zc_popup_dialog(keyboard_control_dlg,3);
6677
6678 if(ret==3) // OK
6679 {
6680 int32_t ukeys[num_ukey];
6681 load_ukeys(ukeys);
6682 std::vector<std::string> uniqueError;
6683 for(int32_t q = 0; q < num_ukey; ++q)
6684 {
6685 for(int32_t p = q+1; p < num_ukey; ++p)
6686 {
6687 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6688 {
6689 char buf[64];
6690 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6691 std::string str(buf);
6692 uniqueError.push_back(str);
6693 }
6694 }
6695 }
6696 if(uniqueError.size() == 0)
6697 {
6698 done = true;
6699 save_control_configs(true);
6700 }
6701 else
6702 {
6703 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6704 box_out("Cannot have duplicate keybinds!"); box_eol();
6705 for(std::vector<std::string>::iterator it = uniqueError.begin();
6706 it != uniqueError.end(); ++it)
6707 {
6708 box_out((*it).c_str()); box_eol();
6709 }
6710 box_end(true);
6711 }
6712 }
6713 else // Cancel
6714 {
6715 Akey = a;
6716 Bkey = b;
6717 Skey = s;
6718 Lkey = l;
6719 Rkey = r;
6720 Pkey = p;
6721 Exkey1 = ex1;
6722 Exkey2 = ex2;
6723 Exkey3 = ex3;
6724 Exkey4 = ex4;
6725 DUkey = du;
6726 DDkey = dd;
6727 DLkey = dl;
6728 DRkey = dr;
6729 cheat_modifier_keys[0] = mod1a;
6730 cheat_modifier_keys[1] = mod1b;
6731 cheat_modifier_keys[2] = mod2a;
6732 cheat_modifier_keys[3] = mod2b;
6733
6734 done=true;
6735 }
6736
6737 rest(1);
6738 }
6739
6740 return D_O_K;
6741 }
6742
6743 int32_t onGamepad()
6744 {
6745 int32_t a = Abtn;
6746 int32_t b = Bbtn;
6747 int32_t s = Sbtn;
6748 int32_t l = Lbtn;
6749 int32_t r = Rbtn;
6750 int32_t m = Mbtn;
6751 int32_t p = Pbtn;
6752 int32_t ex1 = Exbtn1;
6753 int32_t ex2 = Exbtn2;
6754 int32_t ex3 = Exbtn3;
6755 int32_t ex4 = Exbtn4;
6756 int32_t up = DUbtn;
6757 int32_t down = DDbtn;
6758 int32_t left = DLbtn;
6759 int32_t right = DRbtn;
6760
6761 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6762 if(analog_movement)
6763 gamepad_dlg[56].flags|=D_SELECTED;
6764 else
6765 gamepad_dlg[56].flags&=~D_SELECTED;
6766
6767 large_dialog(gamepad_dlg);
6768
6769 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6770
6771 if(ret == 4) //OK
6772 {
6773 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6774 save_control_configs(false);
6775 }
6776 else //Cancel
6777 {
6778 Abtn = a;
6779 Bbtn = b;
6780 Sbtn = s;
6781 Lbtn = l;
6782 Rbtn = r;
6783 Mbtn = m;
6784 Pbtn = p;
6785 Exbtn1 = ex1;
6786 Exbtn2 = ex2;
6787 Exbtn3 = ex3;
6788 Exbtn4 = ex4;
6789 DUbtn = up;
6790 DDbtn = down;
6791 DLbtn = left;
6792 DRbtn = right;
6793 }
6794
6795 return D_O_K;
6796 }
6797
6798 int32_t onCheatKeys()
6799 {
6800 int32_t oldcheats[Cheat::Last][2];
6801 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6802
6803 bool done=false;
6804
6805 while(!done)
6806 {
6807 bool confirm = false;
6808 CheatKeysDialog(&confirm).show();
6809 if(confirm) // OK
6810 {
6811 std::vector<std::string> uniqueError;
6812 char buf[512];
6813 for(size_t q = 1; q < Cheat::Last; ++q)
6814 {
6815 if(cheatkeys[q][1] && !cheatkeys[q][0])
6816 {
6817 cheatkeys[q][0] = cheatkeys[q][1];
6818 cheatkeys[q][1] = 0;
6819 }
6820 }
6821 for(size_t q = 1; q < Cheat::Last; ++q)
6822 {
6823 if(!bindable_cheat((Cheat)q)) continue;
6824 for(size_t p = q+1; p < Cheat::Last; ++p)
6825 {
6826 if(!bindable_cheat((Cheat)p)) continue;
6827 for(size_t q2 = 0; q2 <= 1; ++q2)
6828 for(size_t p2 = 0; p2 <= 1; ++p2)
6829 {
6830 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6831 {
6832 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6833 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6834 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6835 get_keystr(cheatkeys[q][q2])));
6836 }
6837 }
6838 }
6839 }
6840 if(uniqueError.size() == 0)
6841 {
6842 done = true;
6843 save_cheatkeys();
6844 }
6845 else
6846 {
6847 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6848 box_out("Cannot have duplicate keybinds!"); box_eol();
6849 for(std::vector<std::string>::iterator it = uniqueError.begin();
6850 it != uniqueError.end(); ++it)
6851 {
6852 box_out((*it).c_str()); box_eol();
6853 }
6854 box_end(true);
6855 }
6856 }
6857 else // Cancel
6858 {
6859 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6860 done=true;
6861 }
6862 rest(1);
6863 }
6864
6865 return D_O_K;
6866 }
6867
6868 int32_t onSound()
6869 {
6870 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6871 {
6872 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6873 {
6874 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6875 }
6876 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6877 {
6878 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6879 }
6880 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6881 {
6882 emusic_volume = (int32_t)FFCore.usr_music_volume;
6883 }
6884 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6885 {
6886 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6887 }
6888 }
6889 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6890 {
6891 pan_style = (int32_t)FFCore.usr_panstyle;
6892 }
6893
6894 int32_t m = midi_volume;
6895 int32_t d = digi_volume;
6896 int32_t e = emusic_volume;
6897 int32_t b = zcmusic_bufsz;
6898 int32_t s = sfx_volume;
6899 int32_t p = pan_style;
6900 pan_style = vbound(pan_style,0,3);
6901
6902 sound_dlg[0].dp2=get_zc_font(font_lfont);
6903
6904 large_dialog(sound_dlg);
6905
6906 midi_dp[1] = sound_dlg[6].x;
6907 midi_dp[2] = sound_dlg[6].y;
6908 digi_dp[1] = sound_dlg[7].x;
6909 digi_dp[2] = sound_dlg[7].y;
6910 emus_dp[1] = sound_dlg[8].x;
6911 emus_dp[2] = sound_dlg[8].y;
6912 buf_dp[1] = sound_dlg[9].x;
6913 buf_dp[2] = sound_dlg[9].y;
6914 sfx_dp[1] = sound_dlg[10].x;
6915 sfx_dp[2] = sound_dlg[10].y;
6916 pan_dp[1] = sound_dlg[11].x;
6917 pan_dp[2] = sound_dlg[11].y;
6918 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6919 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6920 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6921 sound_dlg[18].d2 = zcmusic_bufsz;
6922 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6923 sound_dlg[20].d2 = pan_style;
6924
6925 int32_t ret = zc_popup_dialog(sound_dlg,1);
6926
6927 if(ret==2)
6928 {
6929 master_volume(digi_volume,midi_volume);
6930 if (zcmusic)
6931 zcmusic_set_volume(zcmusic, emusic_volume);
6932
6933 int32_t temp_volume = sfx_volume;
6934 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
6935 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6936 for(int32_t i=0; i<WAV_COUNT; ++i)
6937 {
6938 //allegro assertion fails when passing in -1 as voice -DD
6939 if(sfx_voice[i] > 0)
6940 voice_set_volume(sfx_voice[i], temp_volume);
6941 }
6942 zc_set_config(sfx_sect,"digi",digi_volume);
6943 zc_set_config(sfx_sect,"midi",midi_volume);
6944 zc_set_config(sfx_sect,"sfx",sfx_volume);
6945 zc_set_config(sfx_sect,"emusic",emusic_volume);
6946 zc_set_config(sfx_sect,"pan",pan_style);
6947 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6948 }
6949 else
6950 {
6951 midi_volume = m;
6952 digi_volume = d;
6953 emusic_volume = e;
6954 zcmusic_bufsz = b;
6955 sfx_volume = s;
6956 pan_style = p;
6957 }
6958
6959 return D_O_K;
6960 }
6961
6962 int32_t queding(char const* s1, char const* s2, char const* s3)
6963 {
6964 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6965 }
6966
6967 int32_t onQuit()
6968 {
6969 if(Playing)
6970 {
6971 int32_t ret=0;
6972
6973 if(get_qr(qr_NOCONTINUE))
6974 {
6975 if(standalone_mode)
6976 {
6977 ret=queding("End current game?",
6978 "The continue screen is disabled; the game",
6979 "will be reloaded from the last save.");
6980 }
6981 else
6982 {
6983 ret=queding("End current game?",
6984 "The continue screen is disabled. You will",
6985 "be returned to the file select screen.");
6986 }
6987 }
6988 else
6989 ret=queding("End current game?",NULL,NULL);
6990
6991 if(ret==1)
6992 {
6993 disableClickToFreeze=false;
6994 Quit=qQUIT;
6995
6996 // Trying to evade a door repair charge?
6997 if(repaircharge)
6998 {
6999 game->change_drupy(-repaircharge);
7000 repaircharge=0;
7001 }
7002
7003 return D_CLOSE;
7004 }
7005 }
7006
7007 return D_O_K;
7008 }
7009
7010 int32_t onTryQuitMenu()
7011 {
7012 return onTryQuit(true);
7013 }
7014
7015 int32_t onTryQuit(bool inMenu)
7016 {
7017 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7018 {
7019 if(active_cutscene.can_f6())
7020 {
7021 if(get_qr(qr_OLD_F6))
7022 {
7023 if(inMenu) onQuit();
7024 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7025 }
7026 else
7027 {
7028 disableClickToFreeze=false;
7029 GameFlags |= GAMEFLAG_TRYQUIT;
7030 }
7031 return D_CLOSE;
7032 }
7033 else active_cutscene.error();
7034 }
7035
7036 return D_O_K;
7037 }
7038
7039 int32_t onReset()
7040 {
7041 if(queding(" Reset system? ",NULL,NULL)==1)
7042 {
7043 disableClickToFreeze=false;
7044 Quit=qRESET;
7045 replay_quit();
7046 return D_CLOSE;
7047 }
7048
7049 return D_O_K;
7050 }
7051
7052 int32_t onExit()
7053 {
7054 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7055 {
7056 Quit=qEXIT;
7057 return D_CLOSE;
7058 }
7059
7060 return D_O_K;
7061 }
7062
7063 int32_t onTitle_NES()
7064 {
7065 title_version=0;
7066 zc_set_config(cfg_sect,"title",title_version);
7067 return D_O_K;
7068 }
7069 int32_t onTitle_DX()
7070 {
7071 title_version=1;
7072 zc_set_config(cfg_sect,"title",title_version);
7073 return D_O_K;
7074 }
7075 int32_t onTitle_25()
7076 {
7077 title_version=2;
7078 zc_set_config(cfg_sect,"title",title_version);
7079 return D_O_K;
7080 }
7081
7082 int32_t onDebug()
7083 {
7084 if(debug_enabled)
7085 set_debug(!get_debug());
7086 return D_O_K;
7087 }
7088
7089 int32_t onHeartBeep()
7090 {
7091 heart_beep=!heart_beep;
7092 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7093 return D_O_K;
7094 }
7095
7096 int32_t onSaveIndicator()
7097 {
7098 use_save_indicator = use_save_indicator ? 0 : 1;
7099 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7100 return D_O_K;
7101 }
7102
7103 int32_t onEpilepsy()
7104 {
7105 if(jwin_alert3(
7106 "Epilepsy Flash Reduction",
7107 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7108 "Disabling this will restore standard flash and wavy behaviour.",
7109 "Proceed?",
7110 "&Yes",
7111 "&No",
7112 NULL,
7113 'y',
7114 'n',
7115 0,
7116 get_zc_font(font_lfont)) == 1)
7117 {
7118 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7119 zc_set_config("zeldadx","checked_epilepsy",1);
7120 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7121 }
7122 return D_O_K;
7123 }
7124
7125 int32_t onTriforce()
7126 {
7127 for(int32_t i=0; i<MAXINITTABS; ++i)
7128 {
7129 init_tabs[i].flags&=~D_SELECTED;
7130 }
7131
7132 init_tabs[3].flags=D_SELECTED;
7133 return onCheatConsole();
7134 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7135 for(int32_t i=1; i<=8; i++)
7136 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7137
7138 if(zc_popup_dialog (triforce_dlg,-1)==9)
7139 {
7140 for(int32_t i=1; i<=8; i++)
7141 {
7142 game->lvlitems[i] &= ~liTRIFORCE;
7143 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7144 }
7145 }
7146 return D_O_K;*/
7147 }
7148
7149 bool rc = false;
7150 /*
7151 int32_t onEquipment()
7152 {
7153 for (int32_t i=0; i<MAXINITTABS; ++i)
7154 {
7155 init_tabs[i].flags&=~D_SELECTED;
7156 }
7157 init_tabs[0].flags=D_SELECTED;
7158 return onCheatConsole();
7159 }
7160 */
7161
7162 int32_t onItems()
7163 {
7164 for(int32_t i=0; i<MAXINITTABS; ++i)
7165 {
7166 init_tabs[i].flags&=~D_SELECTED;
7167 }
7168
7169 init_tabs[1].flags=D_SELECTED;
7170 return onCheatConsole();
7171 }
7172
7173 static DIALOG getnum_dlg[] =
7174 {
7175 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7176 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7177 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7178 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7179 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7180 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7181 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7182 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7183 };
7184
7185 int32_t getnumber(const char *prompt,int32_t initialval)
7186 {
7187 char buf[20];
7188 sprintf(buf,"%d",initialval);
7189 getnum_dlg[0].dp=(void *)prompt;
7190 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7191 getnum_dlg[2].dp=buf;
7192
7193 large_dialog(getnum_dlg);
7194
7195 if(zc_popup_dialog(getnum_dlg,2)==3)
7196 return atoi(buf);
7197
7198 return initialval;
7199 }
7200
7201 int32_t onLife()
7202 {
7203 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7204 cheats_enqueue(Cheat::Life, value);
7205 return D_O_K;
7206 }
7207
7208 int32_t onHeartC()
7209 {
7210 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7211 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7212 cheats_enqueue(Cheat::MaxLife, max_life);
7213 cheats_enqueue(Cheat::Life, life);
7214 return D_O_K;
7215 }
7216
7217 int32_t onMagicC()
7218 {
7219 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7220 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7221 cheats_enqueue(Cheat::MaxMagic, max_magic);
7222 cheats_enqueue(Cheat::Magic, magic);
7223 return D_O_K;
7224 }
7225
7226 int32_t onRupies()
7227 {
7228 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7229 cheats_enqueue(Cheat::Rupies, value);
7230 return D_O_K;
7231 }
7232
7233 int32_t onMaxBombs()
7234 {
7235 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7236 cheats_enqueue(Cheat::MaxBombs, value);
7237 cheats_enqueue(Cheat::Bombs, value);
7238 return D_O_K;
7239 }
7240
7241 int32_t onRefillLife()
7242 {
7243 cheats_enqueue(Cheat::Life, game->get_maxlife());
7244 return D_O_K;
7245 }
7246 int32_t onRefillMagic()
7247 {
7248 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7249 return D_O_K;
7250 }
7251 int32_t onClock()
7252 {
7253 cheats_enqueue(Cheat::Clock);
7254 return D_O_K;
7255 }
7256
7257 int32_t onQstPath()
7258 {
7259 char path[2048];
7260
7261 chop_path(qstdir);
7262 strcpy(path,qstdir);
7263
7264 go();
7265
7266 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7267 {
7268 chop_path(path);
7269 fix_filename_case(path);
7270 fix_filename_slashes(path);
7271 strcpy(qstdir,path);
7272 strcpy(qstpath,qstdir);
7273 }
7274
7275 comeback();
7276 return D_O_K;
7277 }
7278
7279 #include "dialog/cheat_dialog.h"
7280 int32_t onCheat()
7281 {
7282 call_setcheat_dialog();
7283 game->set_cheat(maxcheat);
7284 if(cheat) game->did_cheat(true);
7285 return D_O_K;
7286 }
7287
7288 int32_t onCheatRupies()
7289 {
7290 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7291 return D_O_K;
7292 }
7293
7294 int32_t onCheatArrows()
7295 {
7296 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7297 return D_O_K;
7298 }
7299
7300 int32_t onCheatBombs()
7301 {
7302 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7303 return D_O_K;
7304 }
7305
7306 // *** screen saver
7307
7308 9284954 int32_t after_time()
7309 {
7310
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(ss_enable == 0)
7311 return INT_MAX;
7312
7313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 0)
7314 return 5 * 60;
7315
7316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 3)
7317 return ss_after * 15 * 60;
7318
7319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 13)
7320 return (ss_after - 3) * 60 * 60;
7321
7322 9284954 return MAX_IDLE + 1;
7323 9284954 }
7324
7325 static const char *after_str[15] =
7326 {
7327 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7328 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7329 "Never"
7330 };
7331
7332 const char *after_list(int32_t index, int32_t *list_size)
7333 {
7334 if(index < 0)
7335 {
7336 *list_size = 15;
7337 return NULL;
7338 }
7339
7340 return after_str[index];
7341 }
7342
7343 116 static ListData after__list(after_list, &font);
7344
7345 static DIALOG scrsaver_dlg[] =
7346 {
7347 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7348 116 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7349 116 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7350 116 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7351 116 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7352 116 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7353 116 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7354 116 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7355 116 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7356 116 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7357 116 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7358 116 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7359 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7360 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7361 };
7362
7363 int32_t onScreenSaver()
7364 {
7365 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7366 int32_t oldcfgs[3];
7367 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7368 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7369 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7370
7371 large_dialog(scrsaver_dlg);
7372
7373 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7374
7375 if(ret == 8 || ret == 9)
7376 {
7377 ss_after = scrsaver_dlg[5].d1;
7378 ss_speed = scrsaver_dlg[6].d2;
7379 ss_density = scrsaver_dlg[7].d2;
7380 if(oldcfgs[0] != ss_after)
7381 zc_set_config(cfg_sect,"ss_after",ss_after);
7382 if(oldcfgs[1] != ss_speed)
7383 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7384 if(oldcfgs[2] != ss_density)
7385 zc_set_config(cfg_sect,"ss_density",ss_density);
7386 }
7387
7388 if(ret == 9)
7389 // preview Screen Saver
7390 {
7391 clear_keybuf();
7392 Matrix(ss_speed, ss_density, 30);
7393 system_pal(true);
7394 sys_mouse();
7395 }
7396
7397 return D_O_K;
7398 }
7399
7400 /***** Menus *****/
7401
7402 static MENU game_menu[] =
7403 {
7404 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7405 { (char *)"", NULL, NULL, 0, NULL },
7406 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7407 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7408 { (char *)"", NULL, NULL, 0, NULL },
7409 #ifdef __EMSCRIPTEN__
7410 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7411 #elif defined(ALLEGRO_MACOSX)
7412 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7413 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7414 #else
7415 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7416 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7417 #endif
7418 { NULL, NULL, NULL, 0, NULL }
7419 };
7420
7421 static MENU title_menu[] =
7422 {
7423 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7424 { (char *)"&ZQuest Classic", onTitle_DX, NULL, 0, NULL },
7425 { (char *)"ZQuest Classic &2.50", onTitle_25, NULL, 0, NULL },
7426 { NULL, NULL, NULL, 0, NULL }
7427 };
7428
7429 static MENU snapshot_format_menu[] =
7430 {
7431 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7432 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7433 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7434 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7435 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7436 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7437 { NULL, NULL, NULL, 0, NULL }
7438 };
7439
7440 static MENU controls_menu[] =
7441 {
7442 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7443 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7444 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7445 { NULL, NULL, NULL, 0, NULL }
7446 };
7447
7448 static MENU name_entry_mode_menu[] =
7449 {
7450 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7451 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7452 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7453 { NULL, NULL, NULL, 0, NULL }
7454 };
7455
7456 static void set_controls_menu_active()
7457 {
7458
7459 }
7460
7461 static MENU window_menu[] =
7462 {
7463 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7464 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7465 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7466 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7467 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7468 { NULL, NULL, NULL, 0, NULL }
7469 };
7470 static MENU options_menu[] =
7471 {
7472 { "&Title Screen", NULL, title_menu, 0, NULL },
7473 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7474 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7475 { "&Window Settings", NULL, window_menu, 0, NULL },
7476 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7477 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7478 { NULL, NULL, NULL, 0, NULL }
7479 };
7480 static MENU settings_menu[] =
7481 {
7482 { "&Sound...", onSound, NULL, 0, NULL },
7483 { "C&ontrols", NULL, controls_menu, 0, NULL },
7484 { "", NULL, NULL, 0, NULL },
7485 { "Options", NULL, options_menu, 0, NULL },
7486 { "", NULL, NULL, 0, NULL },
7487 //
7488 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7489 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7490 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7491 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7492 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7493 //
7494 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7495 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7496 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7497 { "", NULL, NULL, 0, NULL },
7498 { "Debu&g", onDebug, NULL, 0, NULL },
7499 //
7500 { NULL, NULL, NULL, 0, NULL }
7501 };
7502
7503
7504 static MENU misc_menu[] =
7505 {
7506 { (char *)"&About...", onAbout, NULL, 0, NULL },
7507 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7508 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7509 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7510 { (char *)"", NULL, NULL, 0, NULL },
7511 //5
7512 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7513 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7514 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7515 { (char *)"", NULL, NULL, 0, NULL },
7516 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7517 //10
7518 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7519 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7520 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7521 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7522 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7523 //15
7524 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7525 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7526 { NULL, NULL, NULL, 0, NULL }
7527 };
7528
7529 static MENU refill_menu[] =
7530 {
7531 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7532 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7533 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7534 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7535 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7536 { NULL, NULL, NULL, 0, NULL }
7537 };
7538
7539 static MENU show_menu[] =
7540 {
7541 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7542 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7543 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7544 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7545 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7546 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7547 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7548 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7549 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7550 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7551 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7552 { (char *)"", NULL, NULL, 0, NULL },
7553 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7554 { (char *)"", NULL, NULL, 0, NULL },
7555 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7556 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7557 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7558 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7559 { NULL, NULL, NULL, 0, NULL }
7560 };
7561
7562 static MENU cheat_menu[] =
7563 {
7564 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7565 { (char *)"", NULL, NULL, 0, NULL },
7566 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7567 { (char *)"", NULL, NULL, 0, NULL },
7568 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7569 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7570 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7571 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7572 { (char *)"", NULL, NULL, 0, NULL },
7573 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7574 { (char *)"", NULL, NULL, 0, NULL },
7575 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7576 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7577 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7578 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7579 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7580 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7581 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7582 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7583 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7584 { NULL, NULL, NULL, 0, NULL }
7585 };
7586
7587 #if DEVLEVEL > 0
7588 int32_t devLogging();
7589 int32_t devDebug();
7590 int32_t devTimestmp();
7591 #if DEVLEVEL > 1
7592 int32_t setCheat();
7593 #endif //DEVLEVEL > 1
7594 enum
7595 {
7596 dv_log,
7597 // dv_dbg,
7598 dv_tmpstmp,
7599 #if DEVLEVEL > 1
7600 dv_nil,
7601 dv_setcheat,
7602 #endif //DEVLEVEL > 1
7603 dv_max
7604 };
7605 static MENU dev_menu[] =
7606 {
7607 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7608 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7609 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7610 #if DEVLEVEL > 1
7611 { (char *)"", NULL, NULL, 0, NULL },
7612 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7613 #endif //DEVLEVEL > 1
7614 { NULL, NULL, NULL, 0, NULL }
7615 };
7616 int32_t devLogging()
7617 {
7618 dev_logging = !dev_logging;
7619 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7620 return D_O_K;
7621 }
7622 // int32_t devDebug()
7623 // {
7624 // dev_debug = !dev_debug;
7625 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7626 // return D_O_K;
7627 // }
7628 int32_t devTimestmp()
7629 {
7630 dev_timestmp = !dev_timestmp;
7631 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7632 return D_O_K;
7633 }
7634 #if DEVLEVEL > 1
7635 int32_t setCheat()
7636 {
7637 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7638 return D_O_K;
7639 }
7640 #endif //DEVLEVEL > 1
7641 #endif //DEVLEVEL > 0
7642
7643 MENU the_player_menu[] =
7644 {
7645 { (char *)"&Game", NULL, game_menu, 0, NULL },
7646 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7647 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7648 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7649 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7650 #if DEVLEVEL > 0
7651 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7652 #endif
7653 { NULL, NULL, NULL, 0, NULL }
7654 };
7655 int32_t onPauseInBackground()
7656 {
7657 if(jwin_alert3(
7658 "Toggle Pause In Background",
7659 "This action will change whether ZC Player pauses when the window loses focus.",
7660 "",
7661 "Proceed?",
7662 "&Yes",
7663 "&No",
7664 NULL,
7665 'y',
7666 'n',
7667 0,
7668 get_zc_font(font_lfont)) == 1)
7669 {
7670 pause_in_background = pause_in_background ? 0 : 1;
7671 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7672 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7673 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7674 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7675 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7676 }
7677 options_menu[5].flags =(pause_in_background)?D_SELECTED:0;
7678 return D_O_K;
7679 }
7680
7681 int32_t onKeyboardEntry()
7682 {
7683 NameEntryMode=0;
7684 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7685 return D_O_K;
7686 }
7687
7688 int32_t onLetterGridEntry()
7689 {
7690 NameEntryMode=1;
7691 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7692 return D_O_K;
7693 }
7694
7695 int32_t onExtLetterGridEntry()
7696 {
7697 NameEntryMode=2;
7698 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7699 return D_O_K;
7700 }
7701
7702 static BITMAP* oldscreen;
7703 int32_t onFullscreenMenu()
7704 {
7705 // super hacks
7706 screen = oldscreen;
7707 if (onFullscreen() == D_REDRAW)
7708 {
7709 oldscreen = screen;
7710 }
7711 screen = menu_bmp;
7712 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7713 return D_O_K;
7714 }
7715
7716 116 void fix_menu()
7717 {
7718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!debug_enabled)
7719 116 settings_menu[13].text = NULL;
7720 116 }
7721
7722 static DIALOG system_dlg[] =
7723 {
7724 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7725 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7726 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7727 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7728 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7729 #ifndef ALLEGRO_MACOSX
7730 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7731 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7732 #else
7733 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7734 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7735 #endif
7736 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7737 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7738 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7739 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7740 };
7741
7742 void reset_snapshot_format_menu()
7743 {
7744 for(int32_t i=0; i<ssfmtMAX; ++i)
7745 {
7746 snapshot_format_menu[i].flags=0;
7747 }
7748 }
7749
7750 int32_t onSetSnapshotFormat()
7751 {
7752 switch(active_menu->text[1])
7753 {
7754 case 'B': //"&BMP"
7755 SnapshotFormat=0;
7756 break;
7757
7758 case 'G': //"&GIF"
7759 SnapshotFormat=1;
7760 break;
7761
7762 case 'J': //"&JPG"
7763 SnapshotFormat=2;
7764 break;
7765
7766 case 'P': //"&PNG"
7767 SnapshotFormat=3;
7768 break;
7769
7770 case 'C': //"PC&X"
7771 SnapshotFormat=4;
7772 break;
7773
7774 case 'T': //"&TGA"
7775 SnapshotFormat=5;
7776 break;
7777
7778 case 'L': //"&LBM"
7779 SnapshotFormat=6;
7780 break;
7781 }
7782 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7783
7784 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7785 return D_O_K;
7786 }
7787
7788
7789 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7790 {
7791 PALETTE tmp;
7792
7793 for(int32_t i=0; i<256; i++)
7794 {
7795 tmp[i].r=r;
7796 tmp[i].g=g;
7797 tmp[i].b=b;
7798 }
7799
7800 fade_interpolate(src,tmp,dest,pos,from,to);
7801 }
7802
7803 13 void system_pal(bool force)
7804 {
7805
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(is_sys_pal && !force) return;
7806 13 is_sys_pal = true;
7807 13 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7808 13 hw_palette = &syspal;
7809 13 update_hw_pal = true;
7810 13 }
7811
7812 static uint32_t entered_sys_pal = 0;
7813 13 void enter_sys_pal()
7814 {
7815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(is_sys_pal)
7816 {
7817 if(entered_sys_pal)
7818 ++entered_sys_pal;
7819 return;
7820 }
7821 13 sys_mouse();
7822 13 system_pal(true);
7823 13 ++entered_sys_pal;
7824 13 }
7825 13 void exit_sys_pal()
7826 {
7827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(entered_sys_pal)
7828 {
7829
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!--entered_sys_pal)
7830 {
7831 13 game_pal();
7832 13 game_mouse();
7833 13 }
7834 13 }
7835 13 }
7836
7837 void switch_out_callback()
7838 {
7839 if (pause_in_background && !MenuOpen)
7840 {
7841 System();
7842 }
7843 }
7844
7845 void switch_in_callback()
7846 {
7847 }
7848
7849 421 void game_pal()
7850 {
7851 421 is_sys_pal = false;
7852 421 entered_sys_pal = 0;
7853 421 hw_palette = &RAMpal;
7854 421 update_hw_pal = true;
7855 421 }
7856
7857 static char bar_str[] = "";
7858
7859 13 void music_pause()
7860 {
7861 //al_pause_duh(tmplayer);
7862 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
7863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(zcmixer->oldtrack)
7864 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7865 13 zc_midi_pause();
7866 13 }
7867
7868 void music_resume()
7869 {
7870 //al_resume_duh(tmplayer);
7871 zcmusic_pause(zcmusic, ZCM_RESUME);
7872 if (zcmixer->oldtrack)
7873 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7874 zc_midi_resume();
7875 }
7876
7877 3358 void music_stop()
7878 {
7879 //al_stop_duh(tmplayer);
7880 //unload_duh(tmusic);
7881 //tmusic=NULL;
7882 //tmplayer=NULL;
7883 3358 zcmusic_stop(zcmusic);
7884 3358 zcmusic_unload_file(zcmusic);
7885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3358 times.
3358 if (zcmixer->oldtrack)
7886 {
7887 zcmusic_stop(zcmixer->oldtrack);
7888 zcmusic_unload_file(zcmixer->oldtrack);
7889 }
7890 //if (zcmixer->newtrack)
7891 //{
7892 // zcmusic_stop(zcmixer->newtrack);
7893 // zcmusic_unload_file(zcmixer->newtrack);
7894 //}
7895 3358 zc_stop_midi();
7896 3358 currmidi=-1;
7897 3358 }
7898
7899 void System()
7900 {
7901 mouse_down=gui_mouse_b();
7902 music_pause();
7903 pause_all_sfx();
7904 MenuOpen = true;
7905 enter_sys_pal();
7906 // FONT *oldfont=font;
7907 // font=tfont;
7908
7909 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7910 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7911
7912 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7913 #if DEVLEVEL > 1
7914 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7915 #endif
7916 game_menu[3].flags =
7917 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7918 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7919 clear_keybuf();
7920
7921 DIALOG_PLAYER *p;
7922
7923 clear_bitmap(menu_bmp);
7924 oldscreen = screen;
7925 screen = menu_bmp;
7926
7927 p = init_dialog(system_dlg,-1);
7928
7929 // drop the menu on startup if menu button pressed
7930 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7931 simulate_keypress(KEY_G << 8);
7932
7933 do
7934 {
7935 if(close_button_quit)
7936 {
7937 close_button_quit = false;
7938 f_Quit(qEXIT);
7939 if(Quit) break;
7940 }
7941 rest(17);
7942
7943 if(mouse_down && !gui_mouse_b())
7944 mouse_down=0;
7945
7946 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7947 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7948 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7949
7950 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7951 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7952 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7953 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7954 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7955 settings_menu[10].flags = NESquit?D_SELECTED:0;
7956 settings_menu[11].flags = volkeys?D_SELECTED:0;
7957
7958 window_menu[0].flags = DragAspect?D_SELECTED:0;
7959 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7960 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7961 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7962 window_menu[4].flags = stretchGame?D_SELECTED:0;
7963
7964 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7965 options_menu[5].flags = (pause_in_background)?D_SELECTED:0;
7966
7967 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7968 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7969 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7970
7971 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7972 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7973 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7974
7975 bool nocheat = (replay_is_replaying() || !Playing
7976 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7977 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7978 cheat_menu[0].flags = 0;
7979 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7980 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7981 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7982 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7983 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7984 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7985 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7986 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7987 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7988
7989 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7990 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7991 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7992 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7993 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7994 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7995 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7996 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7997 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7998 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7999 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8000 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8001 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8002 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8003 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8004
8005 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8006 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8007
8008 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8009 (char *)"Disable recording new saves" :
8010 (char *)"Enable recording new saves";
8011 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8012 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8013 (char *)"Stop recording" :
8014 (char *)"Stop replaying";
8015 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8016 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8017 (char *)"Disable snapshot all frames" :
8018 (char *)"Enable snapshot all frames";
8019
8020 reset_snapshot_format_menu();
8021 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8022
8023 if(debug_enabled)
8024 {
8025 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8026 }
8027
8028 if(gui_mouse_b() && !mouse_down)
8029 break;
8030
8031 // press menu to drop the menu
8032 if(rMbtn())
8033 simulate_keypress(KEY_G << 8);
8034
8035 if(input_idle(true) > after_time())
8036 // run Screeen Saver
8037 {
8038 // Screen saver enabled for now.
8039 clear_keybuf();
8040 Matrix(ss_speed, ss_density, 0);
8041 system_pal(true);
8042 sys_mouse();
8043 broadcast_dialog_message(MSG_DRAW, 0);
8044 }
8045
8046 update_hw_screen();
8047 }
8048 while(update_dialog(p));
8049
8050 screen = oldscreen;
8051
8052 // font=oldfont;
8053 mouse_down=gui_mouse_b();
8054 shutdown_dialog(p);
8055 MenuOpen = false;
8056 if(Quit)
8057 {
8058 kill_sfx();
8059 music_stop();
8060 update_hw_screen();
8061 }
8062 else
8063 {
8064 music_resume();
8065 resume_all_sfx();
8066
8067 if(rc)
8068 ringcolor(false);
8069 }
8070 exit_sys_pal();
8071
8072 eat_buttons();
8073
8074 rc=false;
8075 clear_keybuf();
8076 // text_mode(0);
8077 }
8078
8079 116 void fix_dialogs()
8080 {
8081 116 jwin_center_dialog(about_dlg);
8082 116 jwin_center_dialog(gamepad_dlg);
8083 116 jwin_center_dialog(credits_dlg);
8084 116 jwin_center_dialog(gamemode_dlg);
8085 116 jwin_center_dialog(getnum_dlg);
8086 116 jwin_center_dialog(goto_dlg);
8087 116 jwin_center_dialog(keyboard_control_dlg);
8088 116 jwin_center_dialog(midi_dlg);
8089 116 jwin_center_dialog(quest_dlg);
8090 116 jwin_center_dialog(scrsaver_dlg);
8091 116 jwin_center_dialog(sound_dlg);
8092 116 jwin_center_dialog(triforce_dlg);
8093
8094 // digi_dp[1] += scrx;
8095 // digi_dp[2] += scry;
8096 // midi_dp[1] += scrx;
8097 // midi_dp[2] += scry;
8098 // pan_dp[1] += scrx;
8099 // pan_dp[2] += scry;
8100 // emus_dp[1] += scrx;
8101 // emus_dp[2] += scry;
8102 // buf_dp[1] += scrx;
8103 // buf_dp[2] += scry;
8104 // sfx_dp[1] += scrx;
8105 // sfx_dp[2] += scry;
8106 116 }
8107
8108 /*****************************/
8109 /**** Custom Sound System ****/
8110 /*****************************/
8111
8112 116 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8113 {
8114
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8115 }
8116
8117 // Run an NSF, or a MIDI if the NSF is missing somehow.
8118 149 bool try_zcmusic(char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8119 {
8120 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8121
8122 // Found it
8123
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 79 times.
149 if(newzcmusic!=NULL)
8124 {
8125 70 newzcmusic->fadevolume = 10000;
8126 70 newzcmusic->fadeoutframes = fadeoutframes;
8127
8128 70 zcmixer->newtrack = newzcmusic;
8129
8130 70 zcmusic_stop(zcmusic);
8131 70 zcmusic_unload_file(zcmusic);
8132 70 zc_stop_midi();
8133
8134 70 zcmusic=newzcmusic;
8135 70 int32_t temp_volume = emusic_volume;
8136
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8137 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8138 70 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8139 70 zcmusic_play(zcmusic, temp_volume);
8140
8141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(track>0)
8142 70 zcmusic_change_track(zcmusic,track);
8143
8144 70 return true;
8145 }
8146
8147 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8148
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if(midi>-1000)
8149 jukebox(midi);
8150
8151 79 return false;
8152 149 }
8153
8154 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8155 {
8156 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8157 // Found it
8158 if(newzcmusic!=NULL)
8159 {
8160 zcmusic_stop(zcmusic);
8161 zcmusic_unload_file(zcmusic);
8162 zc_stop_midi();
8163
8164 zcmusic=newzcmusic;
8165 zcmusic_play(zcmusic, emusic_volume);
8166
8167 if(track>0)
8168 zcmusic_change_track(zcmusic,track);
8169
8170 return true;
8171 }
8172
8173 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8174 else if(midi>-1000)
8175 jukebox(midi);
8176
8177 return false;
8178 }
8179
8180 int32_t get_zcmusicpos()
8181 {
8182 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8183 return debugtracething;
8184 return 0;
8185 }
8186
8187 void set_zcmusicpos(int32_t position)
8188 {
8189 zcmusic_set_curpos(zcmusic, position);
8190 }
8191
8192 void set_zcmusicspeed(int32_t speed)
8193 {
8194 zcmusic_set_speed(zcmusic, speed);
8195 }
8196
8197 int32_t get_zcmusiclen()
8198 {
8199 return zcmusic_get_length(zcmusic);
8200 }
8201
8202 void set_zcmusicloop(double start, double end)
8203 {
8204 zcmusic_set_loop(zcmusic, start, end);
8205 }
8206
8207 63871 void jukebox(int32_t index,int32_t loop)
8208 {
8209
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if (is_headless())
8210 63871 return;
8211
8212 music_stop();
8213
8214 if(index<0) index=MAXMIDIS-1;
8215
8216 if(index>=MAXMIDIS) index=0;
8217
8218 music_stop();
8219
8220 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8221 // stuck notes when a song stops. This fixes it.
8222 if(strcmp(midi_driver->name, "DIGMID")==0)
8223 zc_set_volume(0, 0);
8224
8225 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8226 zc_play_midi((MIDI*)tunes[index].data,loop);
8227
8228 if(tunes[index].start>0)
8229 zc_midi_seek(tunes[index].start);
8230
8231 midi_loop_start = tunes[index].loop_start;
8232 midi_loop_end = tunes[index].loop_end;
8233
8234 currmidi=index;
8235 master_volume(digi_volume, midi_volume);
8236 //midi_paused=false;
8237 63871 }
8238
8239 63871 void jukebox(int32_t index)
8240 {
8241
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index<0) index=MAXMIDIS-1;
8242
8243
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index>=MAXMIDIS) index=0;
8244
8245 // do nothing if it's already playing
8246
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63871 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63871 if(index==currmidi && midi_pos>=0)
8247 {
8248 return;
8249 }
8250
8251 63871 jukebox(index,tunes[index].loop);
8252 63871 }
8253
8254 16 void play_DmapMusic()
8255 {
8256
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8257 16 return;
8258
8259 static char tfile[2048];
8260 static int32_t ttrack=0;
8261 bool domidi=false;
8262
8263 int32_t fadeoutframes = 0;
8264 if (zcmusic != NULL)
8265 fadeoutframes = zcmusic->fadeoutframes;
8266
8267 if(DMaps[currdmap].tmusic[0]!=0)
8268 {
8269 if(zcmusic==NULL ||
8270 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8271 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8272 {
8273 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8274 {
8275 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8276 {
8277 if (zcmusic != NULL)
8278 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8279 }
8280 }
8281 else
8282 {
8283 if (zcmusic != NULL)
8284 {
8285 zcmusic_stop(zcmusic);
8286 zcmusic_unload_file(zcmusic);
8287 zcmusic = NULL;
8288 zcmixer->newtrack = NULL;
8289 }
8290
8291 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8292 zcmixer->newtrack = zcmusic;
8293
8294 if (zcmusic != NULL)
8295 {
8296 zc_stop_midi();
8297 strcpy(tfile, DMaps[currdmap].tmusic);
8298 zcmusic_play(zcmusic, emusic_volume);
8299 int32_t temptracks = 0;
8300 temptracks = zcmusic_get_tracks(zcmusic);
8301 temptracks = (temptracks < 2) ? 1 : temptracks;
8302 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8303 zcmusic_change_track(zcmusic, ttrack);
8304 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8305 }
8306 else
8307 {
8308 tfile[0] = 0;
8309 domidi = true;
8310 }
8311 }
8312 }
8313 }
8314 else
8315 {
8316 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8317 {
8318 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8319 }
8320 else if(zcmixer->oldtrack == NULL && zcmixer->newtrack == NULL)
8321 {
8322 domidi = true;
8323 }
8324 }
8325
8326 if(domidi)
8327 {
8328 int32_t m=DMaps[currdmap].midi;
8329
8330 switch(m)
8331 {
8332 case 1:
8333 jukebox(ZC_MIDI_OVERWORLD);
8334 break;
8335
8336 case 2:
8337 jukebox(ZC_MIDI_DUNGEON);
8338 break;
8339
8340 case 3:
8341 jukebox(ZC_MIDI_LEVEL9);
8342 break;
8343
8344 default:
8345 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8346 jukebox(m+MIDIOFFSET_DMAP);
8347 else
8348 music_stop();
8349 }
8350 }
8351 16 }
8352
8353 15753 void playLevelMusic()
8354 {
8355
1/2
✓ Branch 0 taken 15753 times.
✗ Branch 1 not taken.
15753 if (is_headless())
8356 15753 return;
8357
8358 int32_t m=tmpscr->screen_midi;
8359
8360 switch(m)
8361 {
8362 case -2:
8363 music_stop();
8364 break;
8365
8366 case -1:
8367 play_DmapMusic();
8368 break;
8369
8370 case 1:
8371 jukebox(ZC_MIDI_OVERWORLD);
8372 break;
8373
8374 case 2:
8375 jukebox(ZC_MIDI_DUNGEON);
8376 break;
8377
8378 case 3:
8379 jukebox(ZC_MIDI_LEVEL9);
8380 break;
8381
8382 default:
8383 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8384 jukebox(m+MIDIOFFSET_MAPSCR);
8385 else
8386 music_stop();
8387 }
8388 15753 }
8389
8390 116 void master_volume(int32_t dv,int32_t mv)
8391 {
8392
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8393
8394
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8395
8396
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8397 116 int32_t temp_vol = midi_volume;
8398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8399 116 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8400 116 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8401 116 }
8402
8403 /*****************/
8404 /***** SFX *****/
8405 /*****************/
8406
8407 // array of voices, one for each sfx sample in the data file
8408 // 0+ = voice #
8409 // -1 = voice not allocated
8410 116 void Z_init_sound()
8411 {
8412
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<WAV_COUNT; i++)
8413 29696 sfx_voice[i]=-1;
8414
8415
2/2
✓ Branch 0 taken 812 times.
✓ Branch 1 taken 116 times.
928 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8416 812 tunes[i].data = (MIDI*)mididata[i].dat;
8417
8418
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 116 times.
29348 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8419 29232 tunes[ZC_MIDI_COUNT+j].data=NULL;
8420
8421 116 master_volume(digi_volume,midi_volume);
8422 116 }
8423
8424 // returns number of voices currently allocated
8425 int32_t sfx_count()
8426 {
8427 int32_t c=0;
8428
8429 for(int32_t i=0; i<WAV_COUNT; i++)
8430 if(sfx_voice[i]!=-1)
8431 ++c;
8432
8433 return c;
8434 }
8435
8436 // clean up finished samples
8437 9216210 void sfx_cleanup()
8438 {
8439
2/2
✓ Branch 0 taken 2359349760 times.
✓ Branch 1 taken 9216210 times.
2368565970 for(int32_t i=0; i<WAV_COUNT; i++)
8440
3/4
✓ Branch 0 taken 619254 times.
✓ Branch 1 taken 2358730506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619254 times.
2359969014 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8441 {
8442 619254 deallocate_voice(sfx_voice[i]);
8443 619254 sfx_voice[i]=-1;
8444 619254 }
8445 9216210 }
8446
8447 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8448 // if a voice is already allocated (and/or playing), then it just returns true
8449 // Returns true: voice is allocated
8450 // false: unsuccessful
8451 963608 bool sfx_init(int32_t index)
8452 {
8453 // check index
8454
3/4
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721282 times.
963608 if(index<=0 || index>=WAV_COUNT)
8455 242326 return false;
8456
8457
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619271 times.
721282 if(sfx_voice[index]==-1)
8458 {
8459
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409395 times.
619271 if(sfxdat)
8460 {
8461
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8462 {
8463 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8464 209876 }
8465 else
8466 {
8467 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8468 }
8469 209876 }
8470 else
8471 {
8472 409395 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8473 }
8474
8475 619271 int32_t temp_volume = sfx_volume;
8476
1/2
✓ Branch 0 taken 619271 times.
✗ Branch 1 not taken.
619271 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8477 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8478 619271 voice_set_volume(sfx_voice[index], temp_volume);
8479 619271 }
8480
8481 721282 return sfx_voice[index] != -1;
8482 963608 }
8483
8484 int32_t sfx_get_default_freq(int32_t index)
8485 {
8486 if (sfxdat)
8487 {
8488 if (index < Z35)
8489 {
8490 return ((SAMPLE*)sfxdata[index].dat)->freq;
8491 }
8492 else
8493 {
8494 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8495 }
8496 }
8497 else
8498 {
8499 return customsfxdata[index].freq;
8500 }
8501 }
8502
8503 int32_t sfx_get_length(int32_t index)
8504 {
8505 if (sfxdat)
8506 {
8507 if (index < Z35)
8508 {
8509 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8510 }
8511 else
8512 {
8513 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8514 }
8515 }
8516 else
8517 {
8518 return int32_t(customsfxdata[index].len);
8519 }
8520 }
8521
8522 // plays an sfx sample
8523 963608 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8524 {
8525
2/2
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
963608 if(!sfx_init(index))
8526 242326 return;
8527
1/2
✓ Branch 0 taken 721282 times.
✗ Branch 1 not taken.
721282 if (!is_headless())
8528 {
8529 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8530 voice_set_pan(sfx_voice[index], pan);
8531
8532 // Only used by ZScript currently
8533 if (freq <= -1)
8534 {
8535 freq = sfx_get_default_freq(index);
8536 }
8537 voice_set_frequency(sfx_voice[index], freq);
8538
8539 // Only used by ZScript currently
8540 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8541 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8542 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8543 voice_set_volume(sfx_voice[index], temp_volume);
8544
8545 int32_t pos = voice_get_position(sfx_voice[index]);
8546
8547 if (restart) voice_set_position(sfx_voice[index], 0);
8548
8549 if (pos <= 0)
8550 voice_start(sfx_voice[index]);
8551 }
8552
8553
3/4
✓ Branch 0 taken 398006 times.
✓ Branch 1 taken 323276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398006 times.
721282 if (restart && replay_is_debug())
8554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398006 times.
398006 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8555 963608 }
8556
8557 // true if sfx is allocated
8558 67537 bool sfx_allocated(int32_t index)
8559 {
8560
3/4
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9408 times.
67537 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8561 }
8562
8563 // start it (in loop mode) if it's not already playing,
8564 // otherwise adjust it to play in loop mode -DD
8565 178463 void cont_sfx(int32_t index)
8566 {
8567
1/2
✓ Branch 0 taken 178463 times.
✗ Branch 1 not taken.
178463 if (is_headless())
8568 178463 return;
8569
8570 if(!sfx_init(index))
8571 {
8572 return;
8573 }
8574
8575 if(voice_get_position(sfx_voice[index])<=0)
8576 {
8577 voice_set_position(sfx_voice[index],0);
8578 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8579 voice_start(sfx_voice[index]);
8580 }
8581 else
8582 {
8583 adjust_sfx(index, 128, true);
8584 }
8585 178463 }
8586
8587 // adjust parameters while playing
8588 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8589 {
8590
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8591 4075 return;
8592
8593 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8594 voice_set_pan(sfx_voice[index],pan);
8595 4075 }
8596
8597 // pauses a voice
8598 1725 void pause_sfx(int32_t index)
8599 {
8600
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8601 voice_stop(sfx_voice[index]);
8602 1725 }
8603
8604 // resumes a voice
8605 747 void resume_sfx(int32_t index)
8606 {
8607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8608 747 return;
8609
8610 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8611 voice_start(sfx_voice[index]);
8612 747 }
8613
8614 // pauses all active voices
8615 451 void pause_all_sfx()
8616 {
8617
2/2
✓ Branch 0 taken 115456 times.
✓ Branch 1 taken 451 times.
115907 for(int32_t i=0; i<WAV_COUNT; i++)
8618
2/2
✓ Branch 0 taken 115455 times.
✓ Branch 1 taken 1 times.
115457 if(sfx_voice[i]!=-1)
8619 1 voice_stop(sfx_voice[i]);
8620 451 }
8621
8622 // resumes all paused voices
8623 438 void resume_all_sfx()
8624 {
8625
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8626
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8627 voice_start(sfx_voice[i]);
8628 438 }
8629
8630 // stops an sfx and deallocates the voice
8631 7318077 void stop_sfx(int32_t index)
8632 {
8633
3/4
✓ Branch 0 taken 6167423 times.
✓ Branch 1 taken 1150654 times.
✓ Branch 2 taken 6167423 times.
✗ Branch 3 not taken.
7318077 if(index<=0 || index>=WAV_COUNT)
8634 1150654 return;
8635
8636
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6167412 times.
6167423 if(sfx_voice[index]!=-1)
8637 {
8638 11 deallocate_voice(sfx_voice[index]);
8639 11 sfx_voice[index]=-1;
8640 11 }
8641 7318077 }
8642
8643 // Stops SFX played by Hero's item of the given family
8644 128638 void stop_item_sfx(int32_t family)
8645 {
8646 128638 int32_t id=current_item_id(family);
8647
8648
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8649 128083 return;
8650
8651 555 stop_sfx(itemsbuf[id].usesound);
8652 128638 }
8653
8654 3220 void kill_sfx()
8655 {
8656
2/2
✓ Branch 0 taken 824320 times.
✓ Branch 1 taken 3220 times.
827540 for(int32_t i=0; i<WAV_COUNT; i++)
8657
2/2
✓ Branch 0 taken 824314 times.
✓ Branch 1 taken 6 times.
824326 if(sfx_voice[i]!=-1)
8658 {
8659 6 deallocate_voice(sfx_voice[i]);
8660 6 sfx_voice[i]=-1;
8661 6 }
8662 3220 }
8663
8664 659813 int32_t pan(int32_t x)
8665 {
8666
1/4
✓ Branch 0 taken 659813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659813 switch(pan_style)
8667 {
8668 case 0:
8669 return 128;
8670
8671 case 1:
8672 659813 return vbound((x>>1)+68,0,255);
8673
8674 case 2:
8675 return vbound(((x*3)>>2)+36,0,255);
8676 }
8677
8678 return vbound(x,0,255);
8679 659813 }
8680
8681 /*******************************/
8682 /******* Input Handlers ********/
8683 /*******************************/
8684
8685 25088805 bool joybtn(int32_t b)
8686 {
8687
1/2
✓ Branch 0 taken 25088805 times.
✗ Branch 1 not taken.
25088805 if(b == 0)
8688 return false;
8689
1/2
✓ Branch 0 taken 25088805 times.
✗ Branch 1 not taken.
25088805 if (b-1 >= joy[joystick_index].num_buttons)
8690 25088805 return false;
8691
8692 return joy[joystick_index].button[b-1].b !=0;
8693 25088805 }
8694
8695 const char* joybtn_name(int32_t b)
8696 {
8697 if (b <= 0 || b > joy[joystick_index].num_buttons)
8698 return "";
8699
8700 return joy[joystick_index].button[b-1].name;
8701 }
8702
8703 int32_t next_press_key();
8704
8705 int32_t next_press_btn()
8706 {
8707 clear_keybuf();
8708 /*bool b[joy[joystick_index].num_buttons+1];
8709
8710 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8711 b[i]=joybtn(i);*/
8712
8713 //first, we need to wait until they're pressing no buttons
8714 for(;;)
8715 {
8716 if(keypressed())
8717 {
8718 switch(readkey()>>8)
8719 {
8720 case KEY_ESC:
8721 return -1;
8722
8723 case KEY_SPACE:
8724 return 0;
8725 }
8726 }
8727
8728 poll_joystick();
8729 bool done = true;
8730
8731 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8732 {
8733 if(joybtn(i)) done = false;
8734 }
8735
8736 if(done) break;
8737 rest(1);
8738 }
8739
8740 //now, we need to wait for them to press any button
8741 for(;;)
8742 {
8743 if(keypressed())
8744 {
8745 switch(readkey()>>8)
8746 {
8747 case KEY_ESC:
8748 return -1;
8749
8750 case KEY_SPACE:
8751 return 0;
8752 }
8753 }
8754
8755 poll_joystick();
8756
8757 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8758 {
8759 if(joybtn(i)) return i;
8760 }
8761 rest(1);
8762 }
8763 }
8764
8765 1198535 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8766 {
8767
2/2
✓ Branch 0 taken 1194055 times.
✓ Branch 1 taken 4480 times.
1198535 bool ret = btn && !flag;
8768 1198535 flag = rawbtn;
8769
8770 1198535 return ret;
8771 }
8772 190895652 static bool rButton(bool &btn, bool &flag)
8773 {
8774
2/2
✓ Branch 0 taken 184052419 times.
✓ Branch 1 taken 6843233 times.
190895652 bool ret = btn && !flag;
8775 190895652 flag = btn;
8776
8777 190895652 return ret;
8778 }
8779 1846969 static bool rButtonPeek(bool btn, bool flag)
8780 {
8781
2/2
✓ Branch 0 taken 1644296 times.
✓ Branch 1 taken 202673 times.
1846969 if(!btn)
8782 {
8783 1644296 return false;
8784 }
8785
2/2
✓ Branch 0 taken 17699 times.
✓ Branch 1 taken 184974 times.
202673 else if(!flag)
8786 {
8787 17699 return true;
8788 }
8789
8790 184974 return false;
8791 1846969 }
8792
8793 // Updated only by keyboard/gamepad.
8794 // If in replay mode, this is set directly by the replay system.
8795 // This should never be read from directly - use control_state instead.
8796 bool raw_control_state[ZC_CONTROL_STATES];
8797
8798 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8799 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8800 // lasts until the next call to load_control_state.
8801 bool control_state[ZC_CONTROL_STATES];
8802 bool disable_control[ZC_CONTROL_STATES];
8803 bool drunk_toggle_state[11];
8804 bool disabledKeys[127];
8805 bool KeyInput[127];
8806 bool KeyPress[127];
8807
8808 bool key_current_frame[127];
8809 bool key_previous_frame[127];
8810
8811 static bool key_system[127];
8812 static bool key_system_previous[127];
8813 static bool key_system_press[127];
8814
8815 bool button_press[ZC_CONTROL_STATES];
8816 bool button_hold[ZC_CONTROL_STATES];
8817
8818 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8819 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8820 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8821 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8822 #define STICK_PRECISION 56 //define your own sensitivity
8823
8824 7799051 void load_control_state()
8825 {
8826 7799051 load_control_called_this_frame = true;
8827
8828
2/2
✓ Branch 0 taken 4831538 times.
✓ Branch 1 taken 2967513 times.
7799051 if (replay_version_check(8, 11))
8829 {
8830
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8831 53415234 down_control_states[i] = raw_control_state[i];
8832 2967513 }
8833
8834
1/2
✓ Branch 0 taken 7799051 times.
✗ Branch 1 not taken.
7799051 if (!replay_is_replaying())
8835 {
8836 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8837 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8838 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8839 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8840 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8841 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8842 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8843 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8844 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8845 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8846 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8847 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8848 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8849 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8850
8851 if(num_joysticks != 0)
8852 {
8853 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8854 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8855 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8856 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8857 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8858 }
8859 else
8860 {
8861 raw_control_state[14] = false;
8862 raw_control_state[15] = false;
8863 raw_control_state[16] = false;
8864 raw_control_state[17] = false;
8865 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8866 }
8867 }
8868
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7799048 times.
7799051 if (replay_is_active())
8869 {
8870
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6783833 times.
7799048 if (replay_get_version() < 3)
8871 1015215 replay_poll();
8872
3/4
✓ Branch 0 taken 6783833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5022458 times.
✓ Branch 3 taken 1761375 times.
6783833 else if (replay_is_replaying() && replay_get_version() < 6)
8873 1761375 replay_peek_input();
8874
3/4
✓ Branch 0 taken 5022458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2054945 times.
✓ Branch 3 taken 2967513 times.
5022458 else if (replay_is_replaying() && replay_version_check(8, 11))
8875 2967513 replay_peek_input();
8876
2/2
✓ Branch 0 taken 6694758 times.
✓ Branch 1 taken 1104290 times.
7799048 if (replay_get_version() == 8)
8877 1104290 update_keys();
8878 7799048 }
8879
8880 // Some test replay files were made before a serious input bug was fixed, so instead
8881 // of re-doing them or tossing them out, just check for that zplay version.
8882
3/4
✓ Branch 0 taken 7799045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7677145 times.
7799051 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8883
2/2
✓ Branch 0 taken 140382810 times.
✓ Branch 1 taken 7799045 times.
148181855 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8884 {
8885 140382810 control_state[i] = raw_control_state[i];
8886
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90895500 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140382810 if (botched_input && !control_state[i])
8887 47077142 down_control_states[i] = false;
8888 140382810 }
8889 7799045 bool did_bad_cutscene_btn = false;
8890
2/2
✓ Branch 0 taken 7799045 times.
✓ Branch 1 taken 140382810 times.
148181855 for(int q = 0; q < 18; ++q)
8891
3/4
✓ Branch 0 taken 6462860 times.
✓ Branch 1 taken 133919950 times.
✓ Branch 2 taken 6462860 times.
✗ Branch 3 not taken.
140382810 if(control_state[q] && !active_cutscene.can_button(q))
8892 {
8893 control_state[q] = false;
8894 did_bad_cutscene_btn = true;
8895 }
8896
1/2
✓ Branch 0 taken 7799045 times.
✗ Branch 1 not taken.
7799045 if(did_bad_cutscene_btn)
8897 active_cutscene.error();
8898
8899 7799045 button_press[0]=rButton(control_state[0],button_hold[0]);
8900 7799045 button_press[1]=rButton(control_state[1],button_hold[1]);
8901 7799045 button_press[2]=rButton(control_state[2],button_hold[2]);
8902 7799045 button_press[3]=rButton(control_state[3],button_hold[3]);
8903 7799045 button_press[4]=rButton(control_state[4],button_hold[4]);
8904 7799045 button_press[5]=rButton(control_state[5],button_hold[5]);
8905 7799045 button_press[6]=rButton(control_state[6],button_hold[6]);
8906 7799045 button_press[7]=rButton(control_state[7],button_hold[7]);
8907 7799045 button_press[8]=rButton(control_state[8],button_hold[8]);
8908 7799045 button_press[9]=rButton(control_state[9],button_hold[9]);
8909 7799045 button_press[10]=rButton(control_state[10],button_hold[10]);
8910 7799045 button_press[11]=rButton(control_state[11],button_hold[11]);
8911 7799045 button_press[12]=rButton(control_state[12],button_hold[12]);
8912 7799045 button_press[13]=rButton(control_state[13],button_hold[13]);
8913 7799045 button_press[14]=rButton(control_state[14],button_hold[14]);
8914 7799045 button_press[15]=rButton(control_state[15],button_hold[15]);
8915 7799045 button_press[16]=rButton(control_state[16],button_hold[16]);
8916 7799045 button_press[17]=rButton(control_state[17],button_hold[17]);
8917 7799045 }
8918
8919 // Returns true if any game key is pressed. This is needed because keypressed()
8920 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8921 40242214 bool zc_key_pressed()
8922 //may also need to use zc_getrawkey
8923 {
8924
7/10
✓ Branch 0 taken 32591229 times.
✓ Branch 1 taken 7650985 times.
✓ Branch 2 taken 7650985 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7650985 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6394916 times.
✓ Branch 7 taken 6394916 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461268 times.
42703482 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8925
4/6
✓ Branch 0 taken 6394916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6394916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843285 times.
✓ Branch 5 taken 4843285 times.
6394916 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8926
4/6
✓ Branch 0 taken 4843285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843285 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142666 times.
✓ Branch 5 taken 3142666 times.
4843285 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8927
4/6
✓ Branch 0 taken 3142666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142666 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2731732 times.
✓ Branch 5 taken 2731732 times.
3142666 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8928
1/2
✓ Branch 0 taken 2731732 times.
✗ Branch 1 not taken.
2731732 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8929
3/4
✓ Branch 0 taken 2612325 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612325 times.
✗ Branch 3 not taken.
2731732 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8930
3/4
✓ Branch 0 taken 2493431 times.
✓ Branch 1 taken 118894 times.
✓ Branch 2 taken 2493431 times.
✗ Branch 3 not taken.
2612325 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8931
3/4
✓ Branch 0 taken 2478286 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478286 times.
✗ Branch 3 not taken.
2493431 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8932
3/4
✓ Branch 0 taken 2464787 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2464787 times.
✗ Branch 3 not taken.
2478286 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8933
3/4
✓ Branch 0 taken 2462293 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462293 times.
✗ Branch 3 not taken.
2464787 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8934
3/4
✓ Branch 0 taken 2462103 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 2462103 times.
✗ Branch 3 not taken.
2462293 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8935
3/4
✓ Branch 0 taken 2461293 times.
✓ Branch 1 taken 810 times.
✓ Branch 2 taken 2461293 times.
✗ Branch 3 not taken.
2462103 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8936
3/4
✓ Branch 0 taken 2461287 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2461287 times.
✗ Branch 3 not taken.
2461293 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8937
2/2
✓ Branch 0 taken 2461268 times.
✓ Branch 1 taken 19 times.
2461287 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8938 72006144 return true;
8939
8940 2461268 return false;
8941 9284954 }
8942
8943 149218894 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8944 {
8945 149218894 bool ret = false, drunkstate = false, rawret = false;;
8946 149218894 bool* flag = &down_control_states[btn];
8947
2/7
✓ Branch 0 taken 139924604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9294290 times.
149218894 switch(btn)
8948 {
8949 case btnF12:
8950 ret = zc_getkey(KEY_F12, ignoreDisable);
8951 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8952 eatEntirely = false;
8953 break;
8954 case btnF11:
8955 ret = zc_getkey(KEY_F11, ignoreDisable);
8956 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8957 eatEntirely = false;
8958 break;
8959 case btnF5:
8960 ret = zc_getkey(KEY_F5, ignoreDisable);
8961 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8962 eatEntirely = false;
8963 break;
8964 case btnQ:
8965 ret = zc_getkey(KEY_Q, ignoreDisable);
8966 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8967 eatEntirely = false;
8968 break;
8969 case btnI:
8970 ret = zc_getkey(KEY_I, ignoreDisable);
8971 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8972 eatEntirely = false;
8973 break;
8974 case btnM:
8975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9294290 times.
9294290 if(FFCore.kb_typing_mode) return false;
8976 9294290 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8977 9294290 eatEntirely = false;
8978 9294290 break;
8979 default: //control_state[] index
8980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139924604 times.
139924604 if(FFCore.kb_typing_mode) return false;
8981
5/6
✓ Branch 0 taken 139125147 times.
✓ Branch 1 taken 799457 times.
✓ Branch 2 taken 2190363 times.
✓ Branch 3 taken 136934784 times.
✓ Branch 4 taken 2190363 times.
✗ Branch 5 not taken.
139924604 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8982
2/2
✓ Branch 0 taken 7643662 times.
✓ Branch 1 taken 132280942 times.
139924604 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8983
4/4
✓ Branch 0 taken 125762930 times.
✓ Branch 1 taken 14161674 times.
✓ Branch 2 taken 2995 times.
✓ Branch 3 taken 14158679 times.
154086278 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8984 139924604 rawret = raw_control_state[btn];
8985 139924604 }
8986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149218894 times.
149218894 assert(flag);
8987
2/2
✓ Branch 0 taken 95660548 times.
✓ Branch 1 taken 53558346 times.
149218894 if(press)
8988 {
8989
2/2
✓ Branch 0 taken 1846969 times.
✓ Branch 1 taken 51711377 times.
53558346 if(peek)
8990 1846969 ret = rButtonPeek(ret, *flag);
8991
2/2
✓ Branch 0 taken 50512842 times.
✓ Branch 1 taken 1198535 times.
51711377 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8992 1198535 else ret = rButton(ret, *flag, rawret);
8993 53558346 }
8994
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149218894 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149218894 if(eatEntirely && ret) control_state[btn] = false;
8995
3/4
✓ Branch 0 taken 112177277 times.
✓ Branch 1 taken 37041617 times.
✓ Branch 2 taken 112177277 times.
✗ Branch 3 not taken.
149218894 if(drunk && drunkstate) ret = !ret;
8996 149218894 return ret;
8997 149218894 }
8998
8999 7333007 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9000 {
9001 7333007 byte ret = 0;
9002
2/2
✓ Branch 0 taken 5483939 times.
✓ Branch 1 taken 1849068 times.
7333007 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9003
2/2
✓ Branch 0 taken 7332445 times.
✓ Branch 1 taken 562 times.
7333007 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9004
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9005
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9006
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9007
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9008
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9009
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9010 7333007 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9011 }
9012
9013 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9014 {
9015 1114 return intbtn&vals;
9016 }
9017
9018 1767241 bool Up()
9019 {
9020 1767241 return getInput(btnUp);
9021 }
9022 146943 bool Down()
9023 {
9024 146943 return getInput(btnDown);
9025 }
9026 257358 bool Left()
9027 {
9028 257358 return getInput(btnLeft);
9029 }
9030 286551 bool Right()
9031 {
9032 286551 return getInput(btnRight);
9033 }
9034 164908 bool cAbtn()
9035 {
9036 164908 return getInput(btnA);
9037 }
9038 1411891 bool cBbtn()
9039 {
9040 1411891 return getInput(btnB);
9041 }
9042 bool cSbtn()
9043 {
9044 return getInput(btnS);
9045 }
9046 68744 bool cLbtn()
9047 {
9048 68744 return getInput(btnL);
9049 }
9050 68744 bool cRbtn()
9051 {
9052 68744 return getInput(btnR);
9053 }
9054 bool cPbtn()
9055 {
9056 return getInput(btnP);
9057 }
9058 bool cEx1btn()
9059 {
9060 return getInput(btnEx1);
9061 }
9062 bool cEx2btn()
9063 {
9064 return getInput(btnEx2);
9065 }
9066 bool cEx3btn()
9067 {
9068 return getInput(btnEx3);
9069 }
9070 bool cEx4btn()
9071 {
9072 return getInput(btnEx4);
9073 }
9074 bool AxisUp()
9075 {
9076 return getInput(btnAxisUp);
9077 }
9078 bool AxisDown()
9079 {
9080 return getInput(btnAxisDown);
9081 }
9082 bool AxisLeft()
9083 {
9084 return getInput(btnAxisLeft);
9085 }
9086 bool AxisRight()
9087 {
9088 return getInput(btnAxisRight);
9089 }
9090
9091 bool cMbtn()
9092 {
9093 return getInput(btnM);
9094 }
9095 bool cF12()
9096 {
9097 return getInput(btnF12);
9098 }
9099 bool cF11()
9100 {
9101 return getInput(btnF11);
9102 }
9103 bool cF5()
9104 {
9105 return getInput(btnF5);
9106 }
9107 bool cQ()
9108 {
9109 return getInput(btnQ);
9110 }
9111 bool cI()
9112 {
9113 return getInput(btnI);
9114 }
9115
9116 130270 bool rUp()
9117 {
9118 130270 return getInput(btnUp, true);
9119 }
9120 130174 bool rDown()
9121 {
9122 130174 return getInput(btnDown, true);
9123 }
9124 130122 bool rLeft()
9125 {
9126 130122 return getInput(btnLeft, true);
9127 }
9128 129657 bool rRight()
9129 {
9130 129657 return getInput(btnRight, true);
9131 }
9132 3145 bool rAbtn()
9133 {
9134 3145 return getInput(btnA, true);
9135 }
9136 131548 bool rBbtn()
9137 {
9138 131548 return getInput(btnB, true);
9139 }
9140 7395153 bool rSbtn()
9141 {
9142 7395153 return getInput(btnS, true);
9143 }
9144 9284954 bool rMbtn()
9145 {
9146 9284954 return getInput(btnM, true);
9147 }
9148 129441 bool rLbtn()
9149 {
9150 129441 return getInput(btnL, true);
9151 }
9152 129436 bool rRbtn()
9153 {
9154 129436 return getInput(btnR, true);
9155 }
9156 7331617 bool rPbtn()
9157 {
9158 7331617 return getInput(btnP, true);
9159 }
9160 bool rEx1btn()
9161 {
9162 return getInput(btnEx1, true);
9163 }
9164 bool rEx2btn()
9165 {
9166 return getInput(btnEx2, true);
9167 }
9168 140087 bool rEx3btn()
9169 {
9170 140087 return getInput(btnEx3, true);
9171 }
9172 140087 bool rEx4btn()
9173 {
9174 140087 return getInput(btnEx4, true);
9175 }
9176 bool rAxisUp()
9177 {
9178 return getInput(btnAxisUp, true);
9179 }
9180 bool rAxisDown()
9181 {
9182 return getInput(btnAxisDown, true);
9183 }
9184 bool rAxisLeft()
9185 {
9186 return getInput(btnAxisLeft, true);
9187 }
9188 bool rAxisRight()
9189 {
9190 return getInput(btnAxisRight, true);
9191 }
9192
9193 bool rF11()
9194 {
9195 return getInput(btnF11, true);
9196 }
9197 bool rQ()
9198 {
9199 return getInput(btnQ, true);
9200 }
9201 bool rI()
9202 {
9203 return getInput(btnI, true);
9204 }
9205
9206 18221767 bool DrunkUp()
9207 {
9208 18221767 return getInput(btnUp, false, true);
9209 }
9210 16885102 bool DrunkDown()
9211 {
9212 16885102 return getInput(btnDown, false, true);
9213 }
9214 10286365 bool DrunkLeft()
9215 {
9216 10286365 return getInput(btnLeft, false, true);
9217 }
9218 8832532 bool DrunkRight()
9219 {
9220 8832532 return getInput(btnRight, false, true);
9221 }
9222 8034063 bool DrunkcAbtn()
9223 {
9224 8034063 return getInput(btnA, false, true);
9225 }
9226 7848592 bool DrunkcBbtn()
9227 {
9228 7848592 return getInput(btnB, false, true);
9229 }
9230 7262487 bool DrunkcEx1btn()
9231 {
9232 7262487 return getInput(btnEx1, false, true);
9233 }
9234 7262507 bool DrunkcEx2btn()
9235 {
9236 7262507 return getInput(btnEx2, false, true);
9237 }
9238 bool DrunkcSbtn()
9239 {
9240 return getInput(btnS, false, true);
9241 }
9242 bool DrunkcMbtn()
9243 {
9244 return getInput(btnM, false, true);
9245 }
9246 bool DrunkcLbtn()
9247 {
9248 return getInput(btnL, false, true);
9249 }
9250 bool DrunkcRbtn()
9251 {
9252 return getInput(btnR, false, true);
9253 }
9254 bool DrunkcPbtn()
9255 {
9256 return getInput(btnP, false, true);
9257 }
9258
9259 bool DrunkrUp()
9260 {
9261 return getInput(btnUp, true, true);
9262 }
9263 bool DrunkrDown()
9264 {
9265 return getInput(btnDown, true, true);
9266 }
9267 bool DrunkrLeft()
9268 {
9269 return getInput(btnLeft, true, true);
9270 }
9271 bool DrunkrRight()
9272 {
9273 return getInput(btnRight, true, true);
9274 }
9275 6080192 bool DrunkrAbtn()
9276 {
9277 6080192 return getInput(btnA, true, true);
9278 }
9279 6097024 bool DrunkrBbtn()
9280 {
9281 6097024 return getInput(btnB, true, true);
9282 }
9283 71669 bool DrunkrEx1btn()
9284 {
9285 71669 return getInput(btnEx1, true, true);
9286 }
9287 71662 bool DrunkrEx2btn()
9288 {
9289 71662 return getInput(btnEx2, true, true);
9290 }
9291 bool DrunkrEx3btn()
9292 {
9293 return getInput(btnEx3, true, true);
9294 }
9295 bool DrunkrEx4btn()
9296 {
9297 return getInput(btnEx4, true, true);
9298 }
9299 bool DrunkrSbtn()
9300 {
9301 return getInput(btnS, true, true);
9302 }
9303 bool DrunkrMbtn()
9304 {
9305 return getInput(btnM, true, true);
9306 }
9307 6687269 bool DrunkrLbtn()
9308 {
9309 6687269 return getInput(btnL, true, true);
9310 }
9311 6683794 bool DrunkrRbtn()
9312 {
9313 6683794 return getInput(btnR, true, true);
9314 }
9315 bool DrunkrPbtn()
9316 {
9317 return getInput(btnP, true, true);
9318 }
9319
9320 9336 void eat_buttons()
9321 {
9322 9336 getInput(btnA, true, false, true);
9323 9336 getInput(btnB, true, false, true);
9324 9336 getInput(btnS, true, false, true);
9325 9336 getInput(btnM, true, false, true);
9326 9336 getInput(btnL, true, false, true);
9327 9336 getInput(btnR, true, false, true);
9328 9336 getInput(btnP, true, false, true);
9329 9336 getInput(btnEx1, true, false, true);
9330 9336 getInput(btnEx2, true, false, true);
9331 9336 getInput(btnEx3, true, false, true);
9332 9336 getInput(btnEx4, true, false, true);
9333 9336 }
9334
9335 // Is true for the _first frame_ of a key press.
9336 // But! it is possible that a script manually sets the value of KeyPress,
9337 // in which case it will be restored to the "true" value based on `key_current_frame`
9338 // and `key_previous_frame` on the next frame.
9339 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9340 {
9341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9343 {
9344 case KEY_F7:
9345 case KEY_F8:
9346 case KEY_F9:
9347 return KeyPress[k];
9348
9349 default:
9350
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9351 }
9352 13 }
9353
9354 // Is true for _every frame_ a key is held down.
9355 // But! it is possible that a script manually sets the value of KeyInput,
9356 // in which case it will be restored to the "true" value based on `key_current_frame`
9357 // on the next frame.
9358 bool zc_getkey(int32_t k, bool ignoreDisable)
9359 {
9360 if(ignoreDisable) return KeyInput[k];
9361 switch(k)
9362 {
9363 case KEY_F7:
9364 case KEY_F8:
9365 case KEY_F9:
9366 return KeyInput[k];
9367
9368 default:
9369 return KeyInput[k] && !disabledKeys[k];
9370 }
9371 }
9372
9373 // Reads (and then clears) the current frame key state directly.
9374 // Scripts can also modify `key_current_frame`.
9375 300 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9376 {
9377
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 298 times.
300 if(zc_getrawkey(k, ignoreDisable))
9378 {
9379 2 _key[k]=key[k]=key_current_frame[k]=0;
9380 2 return true;
9381 }
9382 298 _key[k]=key[k]=key_current_frame[k]=0;
9383 298 return false;
9384 300 }
9385
9386 // Reads the current frame key state directly.
9387 // Scripts can also modify `key_current_frame`.
9388 63238933 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9389 {
9390
2/2
✓ Branch 0 taken 53953953 times.
✓ Branch 1 taken 9284980 times.
63238933 if(ignoreDisable) return key_current_frame[k];
9391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284980 times.
9284980 switch(k)
9392 {
9393 case KEY_F7:
9394 case KEY_F8:
9395 case KEY_F9:
9396 return key_current_frame[k];
9397
9398 default:
9399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284980 times.
9284980 return key_current_frame[k] && !disabledKeys[k];
9400 }
9401 63238933 }
9402
9403 // Only used for a handful of keys, like tilde and Function keys.
9404 // This state is never read within the game.
9405 // It exists so that all keyboard input still functions during replay,
9406 // without inadvertently doing things like toggling throttling if the player
9407 // presses ~
9408 9284954 bool zc_get_system_key(int32_t k)
9409 {
9410 9284954 return key_system[k];
9411 }
9412
9413 // True for the _first_ frame of a key press.
9414 83564586 bool zc_read_system_key(int32_t k)
9415 {
9416 83564586 return key_system_press[k];
9417 }
9418
9419 1179189158 bool is_system_key(int32_t k)
9420 {
9421
2/2
✓ Branch 0 taken 1095624572 times.
✓ Branch 1 taken 83564586 times.
1179189158 switch (k)
9422 {
9423 case KEY_BACKQUOTE:
9424 case KEY_CLOSEBRACE:
9425 case KEY_END:
9426 case KEY_HOME:
9427 case KEY_OPENBRACE:
9428 case KEY_PGDN:
9429 case KEY_PGUP:
9430 case KEY_TAB:
9431 case KEY_TILDE:
9432 83564586 return true;
9433 }
9434 1095624572 return is_Fkey(k);
9435 1179189158 }
9436
9437 9284954 void update_system_keys()
9438 {
9439
2/2
✓ Branch 0 taken 1179189158 times.
✓ Branch 1 taken 9284954 times.
1188474112 for (int32_t q = 0; q < 127; ++q)
9440 {
9441
2/2
✓ Branch 0 taken 194984034 times.
✓ Branch 1 taken 984205124 times.
1179189158 if (!is_system_key(q))
9442 984205124 continue;
9443
9444 194984034 key_system[q] = key[q];
9445
1/2
✓ Branch 0 taken 194984034 times.
✗ Branch 1 not taken.
194984034 key_system_press[q] = key_system[q] && !key_system_previous[q];
9446 194984034 key_system_previous[q] = key_system[q];
9447 194984034 }
9448 9284954 }
9449
9450 10389244 void update_keys()
9451 {
9452
2/2
✓ Branch 0 taken 1319433988 times.
✓ Branch 1 taken 10389244 times.
1329823232 for (int32_t q = 0; q < 127; ++q)
9453 {
9454 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9455
1/2
✓ Branch 0 taken 1319433988 times.
✗ Branch 1 not taken.
1319433988 if (!replay_is_replaying())
9456 key_current_frame[q] = key[q];
9457
9458
2/2
✓ Branch 0 taken 1309647613 times.
✓ Branch 1 taken 9786375 times.
1319433988 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9459 1319433988 KeyInput[q] = key_current_frame[q];
9460 1319433988 key_previous_frame[q] = key_current_frame[q];
9461 1319433988 }
9462 10389244 }
9463
9464 bool zc_disablekey(int32_t k, bool val)
9465 {
9466 switch(k)
9467 {
9468 case KEY_F7:
9469 case KEY_F8:
9470 case KEY_F9:
9471 return false;
9472
9473 default:
9474 disabledKeys[k] = val;
9475 return true;
9476 }
9477 }
9478
9479 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9480 {
9481 timer=timer;
9482 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9483 }
9484